godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.48k stars 21.08k forks source link

[macOS] Compile errors when building with C# #40572

Closed asmaloney closed 4 years ago

asmaloney commented 4 years ago

Godot version:

Godot 3.2.x from commit 7b4b83e9dcb91b44b39e8cc87df3ddecdb29b689

OS/device including version:

macOS 10.14.6

Issue description:

Trying to follow the instructions to build with C# support.

I'm using the following options to scons:

target=debug -j 8 dev=yes use_llvm=yes tools=yes module_mono_enabled=yes mono_glue=no

This produces many build errors because -Werror and -Winconsistent-missing-override are both specified.

Example build errors:

In file included from modules/mono/csharp_script.cpp:31:
modules/mono/csharp_script.h:70:2: error: 'get_class' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
        GDCLASS(CSharpScript, Script);
        ^
./core/object.h:271:17: note: expanded from macro 'GDCLASS'
        virtual String get_class() const {                                                                                                  \
                       ^
./core/script_language.h:101:2: note: overridden virtual function is here
        GDCLASS(Script, Resource);
        ^
./core/object.h:271:17: note: expanded from macro 'GDCLASS'
        virtual String get_class() const {                                                                                                  \
                       ^
In file included from modules/mono/csharp_script.cpp:31:
modules/mono/csharp_script.h:70:2: error: '_get_class_namev' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
        GDCLASS(CSharpScript, Script);
        ^
./core/object.h:274:28: note: expanded from macro 'GDCLASS'
        virtual const StringName *_get_class_namev() const {                                                                                \
                                  ^
./core/script_language.h:101:2: note: overridden virtual function is here
        GDCLASS(Script, Resource);
        ^
./core/object.h:274:28: note: expanded from macro 'GDCLASS'
        virtual const StringName *_get_class_namev() const {                                                                                \
                                  ^
Example compile command clang++ -o modules/mono/mono_gd/gd_mono_method.osx.tools.64.o -c -std=gnu++14 -Wctor-dtor-privacy -Wnon-virtual-dtor -g3 -arch x86_64 -mmacosx-version-min=10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Werror -DDEBUG_ENABLED -DDEBUG_MEMORY_ENABLED -DDEBUG_MEMORY_ALLOC -DDISABLE_FORCED_INLINE -DTYPED_METHOD_BIND -DOSX_ENABLED -DUNIX_ENABLED -DGLES_ENABLED -DAPPLE_STYLE_KEYS -DCOREAUDIO_ENABLED -DCOREMIDI_ENABLED -DGL_SILENCE_DEPRECATION -DPTRCALL_ENABLED -DTOOLS_ENABLED -DGDSCRIPT_ENABLED -DMINIZIP_ENABLED -DZSTD_STATIC_LINKING_ONLY -DGLAD_ENABLED -DGLES_OVER_GL -DMODULE_ASSIMP_ENABLED -DMODULE_BMP_ENABLED -DMODULE_BULLET_ENABLED -DMODULE_CAMERA_ENABLED -DMODULE_CSG_ENABLED -DMODULE_CVTT_ENABLED -DMODULE_DDS_ENABLED -DMODULE_ENET_ENABLED -DMODULE_ETC_ENABLED -DMODULE_FREETYPE_ENABLED -DMODULE_GDNATIVE_ENABLED -DMODULE_GDSCRIPT_ENABLED -DMODULE_GRIDMAP_ENABLED -DMODULE_HDR_ENABLED -DMODULE_JPG_ENABLED -DMODULE_JSONRPC_ENABLED -DMODULE_MBEDTLS_ENABLED -DMODULE_MOBILE_VR_ENABLED -DMODULE_MONO_ENABLED -DHAVE_CXX11_THREAD_LOCAL -DGD_MONO_HOT_RELOAD -D_REENTRANT -I/Library/Frameworks/Mono.framework/Versions/Current/include/mono-2.0 -Ithirdparty/libpng -Ithirdparty/glad -Ithirdparty/zstd -Ithirdparty/zlib -Iplatform/osx -I. modules/mono/mono_gd/gd_mono_method.cpp
bruvzg commented 4 years ago

Regression from 0da84b5 (cherry picked from commit 51e1614, without cherry picking 26fcf2b first).

akien-mga commented 4 years ago

Welp, we'll have to be carefully when cherrypicking from now on unless we decide to use override in 3.2 (but it would break third-party code so I'm not in favour of doing it).

asmaloney commented 4 years ago

(cherry picked from commit 51e1614, without cherry picking 26fcf2b first)

I don't think that's correct - you don't want override in 3.2 code.

Removing override seems to be the correct fix.

PR incoming...

akien-mga commented 4 years ago

Fixed by #40573.

Atlinx commented 2 years ago

I'm still getting this issue when compiling mono with a custom module (sg_physics_2d). I'm using the 3.5.stable source code, and I move the custom module under the modules folder prior to compiling.

In file included from modules/sg_physics_2d/register_types.cpp:34:
In file included from modules/sg_physics_2d/./scene/2d/sg_fixed_position_2d.h:27:
modules/sg_physics_2d/./scene/2d/sg_fixed_node_2d.h:35:2: error: 'get_class' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
        GDCLASS(SGFixedNode2D, Node2D);
        ^
./core/object.h:270:17: note: expanded from macro 'GDCLASS'
        virtual String get_class() const {                                                                                                  \
                       ^
./scene/2d/node_2d.h:37:2: note: overridden virtual function is here
        GDCLASS(Node2D, CanvasItem);
        ^
./core/object.h:270:17: note: expanded from macro 'GDCLASS'
        virtual String get_class() const {                                                                                                  \
                       ^
In file included from modules/sg_physics_2d/register_types.cpp:34:
In file included from modules/sg_physics_2d/./scene/2d/sg_fixed_position_2d.h:27:
modules/sg_physics_2d/./scene/2d/sg_fixed_node_2d.h:35:2: error: '_get_class_namev' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
        GDCLASS(SGFixedNode2D, Node2D);
        ^
akien-mga commented 2 years ago

This is an issue with that module, you should report it on that module's repository. Its 3.x branch shouldn't use override.