Novum / vkQuake

Vulkan Quake port based on QuakeSpasm
GNU General Public License v2.0
1.85k stars 225 forks source link

MacOS: Compilation error when making debug build #638

Closed Macil closed 1 year ago

Macil commented 1 year ago

If you try to make a debug build on MacOS using the command meson build --buildtype=debug && ninja -C build, then this error occurs:

[78/150] Compiling C object vkquake.p/Quake_gl_heap.c.o
FAILED: vkquake.p/Quake_gl_heap.c.o
cc -Ivkquake.p -I. -I.. -I/opt/homebrew/include -I/opt/homebrew/include/SDL2 -I/opt/homebrew/opt/mad/include -I/opt/homebrew/Cellar/flac/1.4.2/include -I/opt/homebrew/Cellar/libogg/1.3.5/include -I/opt/homebrew/Cellar/libvorbis/1.3.7/include -I/opt/homebrew/Cellar/opus/1.3.1/include/opus -I/opt/homebrew/Cellar/opusfile/0.12/include/opus -fcolor-diagnostics -include-pch vkquake.p/quakedef.h.pch -Wall -Winvalid-pch -std=gnu11 -O0 -g -D_THREAD_SAFE -Wall -Wno-trigraphs -Wno-unused-function -Werror -DUSE_CODEC_WAVE -DUSE_CODEC_MP3 -DUSE_CODEC_FLAC -DUSE_CODEC_VORBIS -DUSE_CODEC_OPUS -D_DEBUG -MD -MQ vkquake.p/Quake_gl_heap.c.o -MF vkquake.p/Quake_gl_heap.c.o.d -o vkquake.p/Quake_gl_heap.c.o -c ../Quake/gl_heap.c
../Quake/gl_heap.c:891:36: error: illegal initializer type 'atomic_uint32_t' (aka '_Atomic(uint32_t)')
        atomic_uint32_t num_allocations = {0};
                                          ^
1 error generated.
[87/150] Compiling C object vkquake.p/Quake_gl_model.c.o
ninja: build stopped: subcommand failed.

CI didn't catch this because it only does release builds on MacOS (and Linux which might be affected too, dunno).

Changing the line to atomic_uint32_t num_allocations = 0; fixes compilation on MacOS, but breaks Windows debug msvc builds. I'm guessing this is a C-vs-C++ syntax conflict? Not sure what the idiomatic solution looks like here.

Desktop:

Novum commented 1 year ago

There is no C++ in vkQuake. {0} is just stone age C struct initialization syntax. The fix is just to remove the initialization and replace it with Atomic_StoreUInt32

Novum commented 1 year ago

74145bb52caf99787af1e182b5ad8e1c2f5dc8fe