Skip to content

Conversation

charjr
Copy link

@charjr charjr commented Oct 18, 2025

The tail end of an include guard is provided
within the defs.h code blocks,
however #pragma once is used at the top instead.

.. code-block:: c
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#if !defined(GDE_EXPORT)
#if defined(_WIN32)
#define GDE_EXPORT __declspec(dllexport)
#elif defined(__GNUC__)
#define GDE_EXPORT __attribute__((visibility("default")))
#else
#define GDE_EXPORT
#endif
#endif // ! GDE_EXPORT

.. code-block:: c
...
// The sizes can be obtained from the extension_api.json file.
#ifdef BUILD_32
#define STRING_NAME_SIZE 4
#else
#define STRING_NAME_SIZE 8
#endif
// Types.
typedef struct
{
uint8_t data[STRING_NAME_SIZE];
} StringName;
#endif // DEFS_H

I am also failing to compile the example using scons:

/bin/ld: src/gdexample.os:/home/john/Godot/gd-extension-c-example/src/api.h:20: multiple definition of `constructors'; src/api.os:/home/john/Godot/gd-extension-c-example/src/api.h:20: first defined here

Which is either on my end (and I could use some help 🙏 ) or indicative of other problems within this page.

The tail end of an include guard is provided
within the defs.h code blocks,
however #pragma once is used at the top instead.
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me :-)

@mhilbrunner mhilbrunner merged commit 4377697 into godotengine:master Oct 20, 2025
1 check passed
@mhilbrunner
Copy link
Member

Thank you! Merged.

@charjr charjr deleted the remove-include-guard branch October 20, 2025 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants