You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Virtual function with Node* argument - Undefined Symbol Under Linux #1480
I'm not sure if I'm setting up something incorrectly or not. Nevertheless, if I declare a virtual function that contains an argument that is a pointer to Node or any derived class, then Godot fails to load the extension under Linux, telling that there is undefined symbol GetTypeInfo??WhateverArgumentType. Yet it does work fine under Windows (using MS compiler - was unable to compile using MingW).
Just to make sure the error was indeed related to the argument type within the GDVIRTUAL macro, I changed the argument type to Variant and errors went away.
Yes, I did add the GDVIRTUAL_BIND(). Sorry I forgot to mention that. But then, without it I don't think the code would have worked under Windows or with Variant instead of anything derived from Node*.
Again, I might have messed up something in the setup. Yet, because the code does work when not using Node* (or derived) as argument type, I suspect there is something else at play.
Unfortunately no. It's the exact same behavior. Compilation goes OK, but when attempting to open the project comes the undefined symbol error message. It does work very fine with either GDVIRTUAL1(_some_virtual, godot::Variant) or GDVIRTUAL1(_some_virtual, ::godot::Variant) or GDVIRTUAL1(_some_virtual, const godot::Variant&).
One thing to note, if I declare a function to return a pointer to Node* or anything derived, then it will work as long as there isn't any argument with such type.
Inspecting the macro for the declaration of a function with no return and a single argument, there is this:
Since the undefined symbol message always contains GetTypeTypeInfo I suspect there is something going on related to GetTypeInfo<Control*> (or anything derived from Node).
Activity
AThousandShips commentedon Jun 4, 2024
Did you also bind it in the code? You can't just add
GDVIRTUALyou also need to addGDVIRTUAL_BIND(_some_virtual_function, "arg");to_bind_methodsKehom commentedon Jun 4, 2024
Yes, I did add the
GDVIRTUAL_BIND(). Sorry I forgot to mention that. But then, without it I don't think the code would have worked under Windows or withVariantinstead of anything derived fromNode*.Again, I might have messed up something in the setup. Yet, because the code does work when not using
Node*(or derived) as argument type, I suspect there is something else at play.AThousandShips commentedon Jun 5, 2024
Does it work if you do
::Godot::Control?Kehom commentedon Jun 5, 2024
Unfortunately no. It's the exact same behavior. Compilation goes OK, but when attempting to open the project comes the undefined symbol error message. It does work very fine with either
GDVIRTUAL1(_some_virtual, godot::Variant)orGDVIRTUAL1(_some_virtual, ::godot::Variant)orGDVIRTUAL1(_some_virtual, const godot::Variant&).One thing to note, if I declare a function to return a pointer to
Node*or anything derived, then it will work as long as there isn't any argument with such type.Inspecting the macro for the declaration of a function with no return and a single argument, there is this:
method_info.arguments.push_back(::godot::GetTypeInfo<m_type1>::get_class_info());\ method_info.arguments_metadata.push_back(::godot::GetTypeInfo<m_type1>::METADATA);Since the undefined symbol message always contains GetTypeTypeInfo I suspect there is something going on related to
GetTypeInfo<Control*>(or anything derived fromNode).dsnopek commentedon Jun 10, 2024
I can reproduce this error!
I just posted PR #1484 which fixes this in my testing. Please let me know if it works for you!