Updating Lua NuGet 5.4.8 and Fun with Clang RC
Lua 5.4.8 is here!
So it was, once again, time to build the NuGet package. To my surprise, building with Clang as tool chain unexpectedly failed:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\lib\clang\19\include\stdarg.h(22): warning RC4067: unexpected characters following '#if/#elif' directive; newline expected [D:\a\nuget-lua\nuget-lua\compiler\compiler.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\lib\clang\19\include\stdarg.h(22): warning RC4067: unexpected characters following '#if/#elif' directive; newline expected [D:\a\nuget-lua\nuget-lua\compiler\compiler.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\lib\clang\19\include\stddef.h(22): warning RC4067: unexpected characters following '#if/#elif' directive; newline expected [D:\a\nuget-lua\nuget-lua\compiler\compiler.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\lib\clang\19\include\stddef.h(22): warning RC4067: unexpected characters following '#if/#elif' directive; newline expected [D:\a\nuget-lua\nuget-lua\compiler\compiler.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\lib\clang\19\include\stddef.h(51): warning RC4067: unexpected characters following '#if/#elif' directive; newline expected [D:\a\nuget-lua\nuget-lua\compiler\compiler.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\lib\clang\19\include\stddef.h(51): warning RC4067: unexpected characters following '#if/#elif' directive; newline expected [D:\a\nuget-lua\nuget-lua\compiler\compiler.vcxproj]
I searched online for the compiler errors and if there were recent changes to Clang or the visual studio integration or something. But I found nothing. I tried to build the previous version of Lua in my GitHub action, and that one failed as well.
And after some minutes, I finally noticed the important bit! Those are NOT c/cpp compiler errors! Those are RESOURCE COMPILER errors!
I build all binaries, i.e. the Lua compiler, the Lua interpreter, and the Lua dll version, with version information resourced built in. And the resource script for that includes the lua.h
c-header to use the version information defined in that file. As it is a normal c-header as well, it, of course, includes further files, among them the stdarg.h
and stddef.h
triggering the bugs above.
I suspect there was some optimization introduced to those system headers and the Cpp compiler, which is not reflected in the resource compiler. And I don’t blame anyone for that, as the resource compiler is something exotic anyway, and one cannot really expect it to be fully compatible with cpp.
The versioninfo resource script for those projects is generated anyway. So, I fixed this problem by no longer including lua.h
in the version info header, but by duplicating all required defines. Just in case you (or my forgetful future self 😉) run into similar issues in other projects as well.
And with this, also the new NuGet package of Lua is now available.