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

Compile error with MSVC #10071

Closed
RandomShaper opened this issue Aug 3, 2017 · 5 comments · Fixed by #10072 or #10356
Closed

Compile error with MSVC #10071

RandomShaper opened this issue Aug 3, 2017 · 5 comments · Fixed by #10072 or #10356

Comments

@RandomShaper
Copy link
Member

Godot 3.0 fails to compile with MSVC because of its rules for searching include files. Specifically, when compiling modules\gdnative\godot\dictionary.cpp you get this error:

[...]\core/io/json.h(62): error C2079: 'JSON::Token::value' uses undefined class 'Variant'

The problem is that although you'd expect #include "variant.h" in core/io/json.h to include core/variant.h, since MSVC doesn't find it right where json.h is, it looks for it according to this:

In the directories of the currently opened include files, in the reverse order in which they were opened. The search begins in the directory of the parent include file and continues upward through the directories of any grandparent include files.

That is, it seems to go up in the include chain until it reaches the directory of the main file being compiled (modules/gdnative/godot), which happens to contain a variant.h file itself, and that is taken.

I'm not sure how to deal with this. Happens at least with MSVC 2017.

@vnen, have you seen this issue? Any ideas on how to fix?

@Tyler-Yocolano
Copy link

Someone suggested going into the modules\gdnative\godot\dictionary.cpp file and putting #include "core/variant.h" above #include "core/io/json.h"

It worked for me.

@RandomShaper
Copy link
Member Author

Well, that serves as a workaround, but the rules about include paths should be consistent across the whole codebase.

We have to find an universal solution; I mean, it might be inserting full paths like that in every #include, but let's hope someone can think of something better.

@marcelofg55
Copy link
Contributor

Perhaps a better solution for this would be to change the #include "variant.h" to #include "core/variant.h" in json.h?

@RandomShaper
Copy link
Member Author

@Tyler-Yocolano, sorry, I misread you. I thought you were suggesting the same @marcelofg55 has said now.

@karroffel
Copy link
Contributor

I agree that more absolute paths should be used everywhere. I never even considered this kind of problem because it's hidden in core/io.

The sad thing is that it would work just fine if clang-format wouldn't move the #include "core/variant.h" below the line for JSON.

I'll make a PR to fix this in GDNative, but I think in the long run we should use less ambiguous paths.

karroffel added a commit to karroffel/godot that referenced this issue Aug 4, 2017
fixes godotengine#10071. The problem is that the json.h file includes the
local variant.h instead of the "absolute" core/variant.h
RandomShaper added a commit to RandomShaper/godot that referenced this issue Aug 15, 2017
karroffel added a commit to karroffel/godot that referenced this issue Aug 22, 2017
core/ and core/math have been in the default include path, this can
cause trouble when a direction has files with the same basename as
files in core/ or core/math. (see godotengine#10071)

In order to fix such future problems all core/... includes need to
be explicit, preventing the compiler *not* including core files when
files with same basename are present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants