Skip to content

binding_generator: include core/version.hpp in core/defs.hpp - #1944

Merged
dsnopek merged 1 commit into
godotengine:masterfrom
VerdantInteractive:master
Mar 6, 2026
Merged

dsnopek merged 1 commit into
godotengine:masterfrom
VerdantInteractive:master

Conversation

@60k41p

@60k41p 60k41p commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

TypedDictionary fails to compile due to include-order dependency

This fixes use of undeclared identifier 'set_typed' in typed_dictionary.hpp when dictionary.hpp is also included.

Fixes a compile failure where TypedDictionary may report set_typed as undeclared depending on include order. The generated dictionary.hpp uses GODOT_VERSION_MINOR but did not include core/version.hpp, causing the preprocessor guard around set_typed to evaluate before version macros were defined.

This patch updates the generator so Dictionary headers always include godot_cpp/core/version.hpp before version-gated declarations.

This patch adds an include for version.hpp in defs.hpp as a general fix to this & similar potential problems.

Minimal reproducer

File: test/repro_typed_dictionary_include_order.cpp

#include <godot_cpp/variant/dictionary.hpp>
#include <godot_cpp/variant/typed_dictionary.hpp>

#include <godot_cpp/variant/string.hpp>
#include <godot_cpp/variant/variant.hpp>

int main() {
    godot::TypedDictionary<godot::String, godot::Variant> configuration;
    return static_cast<int>(configuration.size());
}

Compile command (from godot-cpp repo root):

g++ -std=c++17 -Iinclude -Igen/include -c test/repro_typed_dictionary_include_order.cpp

Fixes #1942

@60k41p
60k41p requested a review from a team as a code owner March 4, 2026 01:34
@dsnopek

dsnopek commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

I wonder if we should include version.hpp in defs.hpp? It feels like it fits with the other stuff in defs.hpp, but it's generated so it needs to be its own file. And given how much we use the version macros (and will probably use them more in the future), it makes sense to me to have them everywhere

@dsnopek dsnopek added the bug This has been identified as a bug label Mar 4, 2026
@dsnopek dsnopek added this to the 10.x milestone Mar 4, 2026
@60k41p

60k41p commented Mar 5, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!

I wonder if we should include version.hpp in defs.hpp? It feels like it fits with the other stuff in defs.hpp, but it's generated so it needs to be its own file. And given how much we use the version macros (and will probably use them more in the future), it makes sense to me to have them everywhere

Make sense to me. I've pushed the update.

The __has_include (C++ 17) prevents errors / red squiggles in the IDE until it is generated.

@60k41p 60k41p changed the title binding_generator: include core/version.hpp in generated Dictionary header binding_generator: include core/version.hpp in core/defs.hpp Mar 5, 2026

@dsnopek dsnopek left a comment

Copy link
Copy Markdown
Collaborator

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

@dsnopek

dsnopek commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

Ah, sorry, I just noticed this has multiple commits. Can you squash your PR into a single commit?

….hpp when dictionary.hpp is also included.
@60k41p

60k41p commented Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

Ah, sorry, I just noticed this has multiple commits. Can you squash your PR into a single commit?

Done. The presence of a merge commit pulled into my fork made things non-trivial when rebasing but it's sorted now.

BTW it's possible adjust the repo settings to only allow squashed merging of PRs where Github does the commit squashing automatically.

@dsnopek
dsnopek merged commit 9ae37ac into godotengine:master Mar 6, 2026
37 of 38 checks passed
@mrtripie

mrtripie commented Mar 6, 2026

Copy link
Copy Markdown

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This has been identified as a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypedDictionary 'set_typed' identifier not found error when building after updating from 4.4 to 10.0

3 participants