Skip to content

Use complete Godot version for preprocessing conditionals#1947

Open
Naros wants to merge 1 commit intogodotengine:masterfrom
Naros:use-full-version-conditionals
Open

Use complete Godot version for preprocessing conditionals#1947
Naros wants to merge 1 commit intogodotengine:masterfrom
Naros:use-full-version-conditionals

Conversation

@Naros
Copy link
Contributor

@Naros Naros commented Mar 6, 2026

This expands on the current conditional logic for Godot versions by using the full Godot version. I suspect that when Godot's next major version happens, godot-cpp will need to continue to maintain compatibility with at least some Godot 4.x versions. This makes that possible.

@Naros Naros requested a review from a team as a code owner March 6, 2026 20:43
@Naros Naros changed the title Use full Godot Use complete Godot version for preprocessing conditionals Mar 6, 2026
@Naros Naros force-pushed the use-full-version-conditionals branch from 0e97e2b to 8c78f00 Compare March 6, 2026 20:46
@dsnopek
Copy link
Collaborator

dsnopek commented Mar 17, 2026

I don't think this change makes these #ifs any more correct.

When Godot 5 happens, my plan was to reset the GDExtension interface such that all the old numbered functions are removed, and the latest becomes unnumbered. So, for example, classdb_register_extension_class5 (or whatever the latest is) will become just classdb_register_extension_class, and so the check for #if GODOT_VERSION >= 0x040500 to use the 5 version, will be incorrect.

If we want to account for Godot 5, I think it would be better to add something like this to a central location:

#if GODOT_MAJOR_VERSION != 4 || GODOT_MINOR_VERSION < 1
#error "This version of godot-cpp is only compatible with Godot 4.1 or newer"
#endif

That way when Godot 5 comes out, if folks try to use it with an old godot-cpp, they will get a nice message rather than cryptic errors about functions not existing. (Or, I guess we could add this check in the Python code before we even get to compiling C++?)

Of course, we could add #ifdefs to allow the same godot-cpp to work with Godot 4 and 5 if we wanted, but that's something we'll only be able to do correctly once we know exactly what Godot 5's GDExtension interface looks like

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants