Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | dcuny |
I’m following the GDExtension tutorial, building on Windows 10, VS 2019.
At this point:
scons platform=windows
I get this error:
register_types.cpp
src\register_types.cpp(28): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
src\register_types.cpp(28): error C2143: syntax error: missing ',' before '*'
src\register_types.cpp(29): error C2065: 'p_interface': undeclared identifier
src\register_types.cpp(29): error C2065: 'p_library': undeclared identifier
src\register_types.cpp(29): error C2065: 'r_initialization': undeclared identifier
scons: *** [src\register_types.windows.template_debug.x86_64.obj] Error 2
scons: building terminated because of errors.
The source code is:
GDExtensionBool GDE_EXPORT example_library_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
Since it’s complaining that it doesn’t recognize the type specifier, I assume that it’s not finding gdextension_interface.h, but the file exists and the definitions are there, such as:
...
typedef const void *GDExtensionMethodBindPtr;
typedef int64_t GDExtensionInt;
typedef uint8_t GDExtensionBool;
typedef uint64_t GDObjectInstanceID;
typedef void *GDExtensionRefPtr;
typedef const void *GDExtensionConstRefPtr;
...
But it appears that perhaps the path to the include file is broken?
I took a look at the SConstruct file, and it looks like
env.Dir("gdextension").abspath
is returning the correct path to gdextension_interface.h. So that’s not it.
dcuny | 2023-06-06 07:55
It looks like I might have a solution. gdextension_interface.h has the following comment:
Each GDExtension should define a C function that matches the signature
of GDExtensionInitializationFunction, and export it so that it can be loaded via
dlopen() or equivalent for the given platform.
For example:
GDExtensionBool my_extension_init(
GDExtensionInterfaceGetProcAddress p_get_proc_address,
GDExtensionClassLibraryPtr p_library,
GDExtensionInitialization *r_initialization);
However, the signature of this function doesn’t match the one provided in the tutorial:
// Initialization.
GDExtensionBool GDE_EXPORT example_library_init(
const GDExtensionInterface *p_interface,
const GDExtensionClassLibraryPtr p_library,
GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
Changing it to this allows the code to compile (I haven’t tested execution yet, though):
// Initialization.
GDExtensionBool GDE_EXPORT example_library_init(
const GDExtensionInterfaceGetProcAddress p_get_proc_address,
const GDExtensionClassLibraryPtr p_library,
GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
dcuny | 2023-06-06 08:09