@@ -306,17 +306,17 @@ We'll start by creating an ``api.h`` file in the ``src`` folder:
306306
307307 // API methods.
308308
309- struct Constructors
309+ extern struct Constructors
310310 {
311311 GDExtensionInterfaceStringNameNewWithLatin1Chars string_name_new_with_latin1_chars;
312312 } constructors;
313313
314- struct Destructors
314+ extern struct Destructors
315315 {
316316 GDExtensionPtrDestructor string_name_destructor;
317317 } destructors;
318318
319- struct API
319+ extern struct API
320320 {
321321 GDExtensionInterfaceClassdbRegisterExtensionClass2 classdb_register_extension_class2;
322322 } api;
@@ -345,6 +345,10 @@ in the ``src`` folder, adding the following code:
345345
346346 GDExtensionClassLibraryPtr class_library = NULL;
347347
348+ struct Constructors constructors;
349+ struct Destructors destructors;
350+ struct API api;
351+
348352 void load_api(GDExtensionInterfaceGetProcAddress p_get_proc_address)
349353 {
350354 // Get helper functions first.
@@ -539,7 +543,7 @@ So let's change the ``api.h`` to include these new functions:
539543.. code-block :: c
540544
541545 ...
542- struct API
546+ extern struct API
543547 {
544548 GDExtensionInterfaceClassdbRegisterExtensionClass2 classdb_register_extension_class2;
545549 GDExtensionInterfaceClassdbConstructObject classdb_construct_object;
@@ -862,13 +866,13 @@ structs:
862866
863867.. code-block :: c
864868
865- struct Constructors {
869+ extern struct Constructors {
866870 ...
867871 GDExtensionVariantFromTypeConstructorFunc variant_from_float_constructor;
868872 GDExtensionTypeFromVariantConstructorFunc float_from_variant_constructor;
869873 } constructors;
870874
871- struct API
875+ extern struct API
872876 {
873877 ...
874878 GDExtensionInterfaceGetVariantFromTypeConstructor get_variant_from_type_constructor;
@@ -1006,19 +1010,19 @@ function for actually binding our custom method.
10061010
10071011.. code-block :: c
10081012
1009- struct Constructors
1013+ extern struct Constructors
10101014 {
10111015 ...
10121016 GDExtensionInterfaceStringNewWithUtf8Chars string_new_with_utf8_chars;
10131017 } constructors;
10141018
1015- struct Destructors
1019+ extern struct Destructors
10161020 {
10171021 ...
10181022 GDExtensionPtrDestructor string_destructor;
10191023 } destructors;
10201024
1021- struct API
1025+ extern struct API
10221026 {
10231027 ...
10241028 GDExtensionInterfaceClassdbRegisterExtensionClassMethod classdb_register_extension_class_method;
@@ -1328,7 +1332,7 @@ the ``api.h`` file:
13281332
13291333.. code-block :: c
13301334
1331- struct API {
1335+ extern struct API {
13321336 ...
13331337 GDExtensionInterfaceClassdbRegisterExtensionClassProperty classdb_register_extension_class_property;
13341338 } api;
@@ -1487,7 +1491,7 @@ We'll also add a new struct to this file, to hold function pointers for custom o
14871491
14881492.. code-block :: c
14891493
1490- struct Operators
1494+ extern struct Operators
14911495 {
14921496 GDExtensionPtrOperatorEvaluator string_name_equal;
14931497 } operators;
@@ -1496,6 +1500,8 @@ Then in the ``api.c`` file we'll load the function pointer from the API:
14961500
14971501.. code-block :: c
14981502
1503+ struct Operators operators;
1504+
14991505 void load_api(GDExtensionInterfaceGetProcAddress p_get_proc_address)
15001506 {
15011507 // Get helper functions first.
@@ -1654,20 +1660,20 @@ new one for holding engine methods to call.
16541660
16551661.. code-block :: c
16561662
1657- struct Constructors
1663+ extern struct Constructors
16581664 {
16591665 ...
16601666 GDExtensionPtrConstructor vector2_constructor_x_y;
16611667 } constructors;
16621668
16631669 ...
16641670
1665- struct Methods
1671+ extern struct Methods
16661672 {
16671673 GDExtensionMethodBindPtr node2d_set_position;
16681674 } methods;
16691675
1670- struct API
1676+ extern struct API
16711677 {
16721678 ...
16731679 GDExtensionInterfaceClassdbGetMethodBind classdb_get_method_bind;
@@ -1678,6 +1684,8 @@ Then in the ``api.c`` file we can grab the function pointers from Godot:
16781684
16791685.. code-block ::
16801686
1687+ struct Methods methods;
1688+
16811689 void load_api(GDExtensionInterfaceGetProcAddress p_get_proc_address)
16821690 {
16831691 // Get helper functions first.
@@ -1807,7 +1815,7 @@ register a signal, the other is a helper function to wrap the signal binding.
18071815
18081816.. code-block :: c
18091817
1810- struct API
1818+ extern struct API
18111819 {
18121820 ...
18131821 GDExtensionInterfaceClassdbRegisterExtensionClassSignal classdb_register_extension_class_signal;
@@ -1928,28 +1936,28 @@ helper function for the call:
19281936
19291937.. code-block :: c
19301938
1931- struct Constructors
1939+ extern struct Constructors
19321940 {
19331941 ...
19341942 GDExtensionVariantFromTypeConstructorFunc variant_from_string_name_constructor;
19351943 GDExtensionVariantFromTypeConstructorFunc variant_from_vector2_constructor;
19361944 } constructors;
19371945
1938- struct Destructors
1946+ extern struct Destructors
19391947 {
19401948 ..
19411949 GDExtensionInterfaceVariantDestroy variant_destroy;
19421950 } destructors;
19431951
19441952 ...
19451953
1946- struct Methods
1954+ extern struct Methods
19471955 {
19481956 ...
19491957 GDExtensionMethodBindPtr object_emit_signal;
19501958 } methods;
19511959
1952- struct API
1960+ extern struct API
19531961 {
19541962 ...
19551963 GDExtensionInterfaceObjectMethodBindCall object_method_bind_call;
0 commit comments