asmaloney / GDExtensionTemplate

📜 A template project for building Godot 4 GDExtensions using CMake
The Unlicense
228 stars 22 forks source link

C4067: unexpected tokens following preprocessor directive - expected a newline #39

Closed oparisy closed 1 year ago

oparisy commented 1 year ago

Hi, I'm using this template under Windows 11, using Visual Studio Community 2022 as a C++ compiler.

I tried a "dry run" by keeping the original source code and renaming the template to "CustomAudioNodes", following instructions.

During the cmake --build CustomAudioStreams-build --parallel step I get the following error:

C:\Dev\GDExtension\CustomAudioStreams\src\GDExtensionTemplate.cpp(12,68): error C2220: the following warning is treated as an error [C:\D
ev\GDExtension\CustomAudioStreams-build\CustomAudioStreams.vcxproj]
C:\Dev\GDExtension\CustomAudioStreams\src\GDExtensionTemplate.cpp(12,68): warning C4067: unexpected tokens following preprocessor directi
ve - expected a newline [C:\Dev\GDExtension\CustomAudioStreams-build\CustomAudioStreams.vcxproj]

This location corresponds to the ( 2, 1, 0 ) parameters following the example macro use:

#if GDEXTENSIONTEMPLATE_VERSION > GDEXTENSIONTEMPLATE_VERSION_CHECK( 2, 1, 0 )

Did I misconfigure something? I can see various ways to work my way around this (removing the example macro call, modifying CompilerWarnings.cmake) but this seemed worth reporting.

asmaloney commented 1 year ago

Hey - thanks for reporting this! I'm not sure why the GitHub workflow isn't catching it. (I build on macOS, so I don't get the Windows warnings.)

I'll take a look. I might have to remove that warning in CompilerWarnings.cmake as you say.

asmaloney commented 1 year ago

Could you please copy-paste the exact code that's being generated in Version.h? I'm not seeing any extra characters. (Version.h will be in the gen directory inside your build directory.)

I'd rather not remove the warning because it can be useful, so I'd like to figure out what's causing it.

asmaloney commented 1 year ago

Oh wait. You know what? I'm being "not smart". I used the GDEXTENSIONTEMPLATE_VERSION macro in file where it won't exist once you rename things. 🤦

I will remove it from that file. In your case you can use the renamed macros which are probably CUSTOMAUDIONODES_VERSION and CUSTOMAUDIONODES_VERSION_CHECK.

asmaloney commented 1 year ago

Thanks again @oparisy !

Good luck with your project.

oparisy commented 1 year ago

Oh, makes perfect sense! I'll retry this from scratch then. Thanks!