Skip to content

Conversation

@BastiaanOlij
Copy link
Collaborator

@BastiaanOlij BastiaanOlij commented Nov 12, 2021

Just working on removing some compiler warning for the test project. Only tested this on Windows so far.

Also added compiling test project to CI

@BastiaanOlij BastiaanOlij self-assigned this Nov 12, 2021
@BastiaanOlij BastiaanOlij force-pushed the fix_compile_warnings branch 3 times, most recently from da08460 to 2699830 Compare November 12, 2021 11:22
@BastiaanOlij
Copy link
Collaborator Author

Ok, so CI fails for mingw because its expecting a library ending on .a instead of .lib, don't know scons well enough to know how to adjust this.

All the warnings I'm still looking into can be found in the CI for Windows, they won't fail the CI

@Calinou Calinou added the bug This has been identified as a bug label Nov 12, 2021
namespace godot {

struct Transform2D;
class Transform2D;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a struct, right? Why change this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's defined as a class. Look up Transform2D.hpp, unless that is our real issue here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does godot-cpp use class Transform2D but the engine uses struct?

I apologize if this is off-topic, but this change seems very weird to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, no idea, probably because we just generate everything as classes, @vnen is this something we should change?


inline Vector2i operator*(const float &p_scalar, const Vector2i &p_vector) {
return p_vector * p_scalar;
float x = (float)p_vector.x * p_scalar;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about making this change, it's more accurate allowing you to multiply a vectori with say 0.5 to half the sizes, but its also slower.

@BastiaanOlij
Copy link
Collaborator Author

Anyone have any idea how to silence these types of warnings? I really have no idea what the compiler is trying to tell me what is wrong here.

D:\a\godot-cpp\godot-cpp\include\godot_cpp/core/method_bind.hpp(253): note: see reference to function template instantiation 'void godot::call_with_variant_args_dv<T,const godot::String&,int>(T *,void (__cdecl Example::* )(const godot::String &,int),const GDNativeVariantPtr *,int,GDNativeCallError &,const std::vector<godot::Variant,std::allocator<godot::Variant>> &)' being compiled
        with
        [
            T=Example
        ]
D:\a\godot-cpp\godot-cpp\include\godot_cpp/core/method_bind.hpp(253): note: while compiling class template member function 'godot::Variant godot::MethodBindT<T,const godot::String &,int>::call(GDExtensionClassInstancePtr,const GDNativeVariantPtr *,const GDNativeInt,GDNativeCallError &) const'
        with
        [
            T=Example
        ]
src\example.cpp(145): note: see reference to class template instantiation 'godot::MethodBindT<T,const godot::String &,int>' being compiled
        with
        [
            T=Example
        ]

@akien-mga
Copy link
Member

akien-mga commented Nov 18, 2021

@BastiaanOlij You missed the actual warning, note: messages are meant to provide additional context for a warning or an error, there should always be a warning: or error: line before them.

D:\a\godot-cpp\godot-cpp\include\godot_cpp/core/binder_common.hpp(238): warning C4267: 'initializing': conversion from 'size_t' to 'int32_t', possible loss of data
D:\a\godot-cpp\godot-cpp\include\godot_cpp/core/method_bind.hpp(253): note: see reference to function template instantiation 'void godot::call_with_variant_args_dv<T,const godot::String&,int>(T *,void (__cdecl Example::* )(const godot::String &,int),const GDNativeVariantPtr *,int,GDNativeCallError &,const std::vector<godot::Variant,std::allocator<godot::Variant>> &)' being compiled
        with
        [
            T=Example
        ]
D:\a\godot-cpp\godot-cpp\include\godot_cpp/core/method_bind.hpp(253): note: while compiling class template member function 'godot::Variant godot::MethodBindT<T,const godot::String &,int>::call(GDExtensionClassInstancePtr,const GDNativeVariantPtr *,const GDNativeInt,GDNativeCallError &) const'
        with
        [
            T=Example
        ]
src\example.cpp(145): note: see reference to class template instantiation 'godot::MethodBindT<T,const godot::String &,int>' being compiled
        with
        [
            T=Example
        ]
D:\a\godot-cpp\godot-cpp\include\godot_cpp/core/class_db.hpp(177): note: see reference to function template instantiation 'godot::MethodBind *godot::create_method_bind<Example,const godot::String&,int>(void (__cdecl Example::* )(const godot::String &,int))' being compiled
src\example.cpp(75): note: see reference to function template instantiation 'godot::MethodBind *godot::ClassDB::bind_method<godot::MethodDefinition,void(__cdecl Example::* )(const godot::String &,int)>(N,M)' being compiled
        with
        [
            N=godot::MethodDefinition,
            M=void (__cdecl Example::* )(const godot::String &,int)
        ]

So the problem is warning C4267: 'initializing': conversion from 'size_t' to 'int32_t', possible loss of data.

@BastiaanOlij
Copy link
Collaborator Author

@akien-mga ah, and that one was really pointing at the wrong line of code because it's a macro and MSVC errors on macros are useless.

I think I've got it though :)

@akien-mga
Copy link
Member

akien-mga commented Nov 19, 2021

Compiling the test project on CI doesn't seem to work well yet, there's some linking issues on macOS and MinGW.

Edit: And actually the "Windows MinGW" build is using MSVC...

Could be split to a separate PR if you want to merge the warning fixes anyway.

@BastiaanOlij
Copy link
Collaborator Author

Compiling the test project on CI doesn't seem to work well yet, there's some linking issues on macOS and MinGW.

Edit: And actually the "Windows MinGW" build is using MSVC...

Could be split to a separate PR if you want to merge the warning fixes anyway.

The problem in both is that it's expecting a different extension for the godot-cpp library. I'll have a look if I can fix that up

@BastiaanOlij BastiaanOlij force-pushed the fix_compile_warnings branch 2 times, most recently from 5fb56ae to d6819a1 Compare November 22, 2021 10:24
@BastiaanOlij BastiaanOlij marked this pull request as ready for review November 22, 2021 10:27
@akien-mga akien-mga merged commit 5cacce7 into godotengine:master Nov 22, 2021
@akien-mga
Copy link
Member

Thanks!

@BastiaanOlij BastiaanOlij deleted the fix_compile_warnings branch November 22, 2021 23:00
@akien-mga akien-mga added this to the 4.0 milestone Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This has been identified as a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants