Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unquoted compatibility_minimum version number in GDExtension C++ example causes unrelated OS+arch error message when extended to include patch version #7864

Closed
dashdotdashdot opened this issue Aug 31, 2023 · 3 comments · Fixed by #7865
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation bug

Comments

@dashdotdashdot
Copy link
Contributor

dashdotdashdot commented Aug 31, 2023

Your Godot version: 4.1.1-stable

Issue description: The example gdexample.gdextension file given in the "Using the GDExtension module" section of the "GDExtension C++ example" page contains an unquoted version number (presently 4.1) that, should the unwary novice extend it to include a patch version (4.1.1 for example) will cause Godot to throw a correct but misleading "No GDExtension library found for current OS and architecture (<os>.<arch>) in configuration file" error for reasons that have nothing to do with the [libraries] section of the file (see below).

When the version number is quoted, like "4.1" or "4.1.1", it works as expected.

The C++ example being de-facto documentation of a .gdextension file's compatibility_minimum field, I suggest having it demonstrate the use of quoted version numbers to help new extension developers avoid this little trap.

Analysis: When unquoted, 4.1 is interpreted by VariantParser as a TK_NUMBER, which it seems to consider ended as soon as it encounters a second decimal period, a number like 4.1.1 making no sense in a numeric context. This means that a gdexample.gdextension file like this (with an unquoted 4.1.1 as the version)

[configuration]

entry_symbol = "example_library_init"
compatibility_minimum = 4.1.1

[libraries]

macos.debug = "res://bin/libgdexample.macos.template_debug.framework"
macos.release = "res://bin/libgdexample.macos.template_release.framework"
windows.debug.x86_32 = "res://bin/libgdexample.windows.template_debug.x86_32.dll"
windows.release.x86_32 = "res://bin/libgdexample.windows.template_release.x86_32.dll"
... (rest omitted)

is seen by ConfigFile as having this structure

[configuration]

entry_symbol = "example_library_init"
compatibility_minimum = 4.1
.1[libraries]macos.debug = "res://bin/libgdexample.macos.template_debug.framework"
macos.release = "res://bin/libgdexample.macos.template_release.framework"
windows.debug.x86_32 = "res://bin/libgdexample.windows.template_debug.x86_32.dll"
... (rest omitted)

which, having no [libraries] section that it can see (macos.release, windows.debug.x86_32, etc. all being parsed as being in the [configuration] section), yields the misleading error, correct from its perspective though it be.

URL to the documentation page: https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/gdextension_cpp_example.html

If you know how to fix the issue you are reporting please
consider opening a pull request. We provide a tutorial on
using git here: https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html,
writing documentation at https://docs.godotengine.org/en/stable/community/contributing/docs_writing_guidelines.html
and contributing to the class reference here: https://docs.godotengine.org/en/stable/community/contributing/updating_the_class_reference.html

@AThousandShips
Copy link
Member

@AThousandShips
Copy link
Member

AThousandShips commented Aug 31, 2023

This would probably also break for a number of cases where the value is not exactly representable, though converting (short) floats from and back to string should be correct

@AThousandShips AThousandShips added the area:manual Issues and PRs related to the Manual/Tutorials section of the documentation label Aug 31, 2023
@dsnopek
Copy link
Contributor

dsnopek commented Aug 31, 2023

Great catch, thanks!

m4gr3d added a commit to m4gr3d/Godot-Android-Samples that referenced this issue Sep 7, 2023
m4gr3d added a commit to m4gr3d/GDExtension-Android-Plugin-Template that referenced this issue Sep 7, 2023
mhilbrunner pushed a commit to mhilbrunner/godot-docs that referenced this issue Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants