godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Switch include order of Godot.hpp and Ref.hpp

Open founderio opened this issue 3 years ago • 1 comments

As Ref<T> uses Object::cast_to<T>, which is defined in Godot.hpp, the includes need to be the other way around to work consistently. If not done like this, inconsistent behaviour during linking/loading may occur and produce errors like this: undefined symbol: ZN5godot6Object7cast_toINS_15SpatialMaterialEEEPT_PKS0

There is a more detailed description in the related issue: Fixes #540

I am not sure if the include of Ref.hpp in Godot.hpp was intentional, thus open for discussion.

Due to that fact: People are using Ref<T> while only including Godot.hpp, which means this is a breaking change.
Not sure if there is a way to solve this without breakage. Maybe move the definition of Object::cast_to<T> to a separate header and include that?

founderio avatar Mar 28 '21 12:03 founderio

@founderio Is this PR still relevant for Godot 4.x and GDExtension? Also, this PR has conflicts that need to be resolved before this can be considered, can you rebase?

aaronfranke avatar Jul 08 '23 17:07 aaronfranke