Here are some issues that I observed when compiling with GCC and Clang. In order to keep Handmade Hero compiling on Linux and OS X with minimal effort I am looking for volunteers to bring these issues to Casey's attention during the stream.
I am not sure how the macro issues should be fixed, though.
There are a couple of issues with the TIMED_FUNCTION macro
GCC complains:
“expected ')' before '__FUNCTION__'
#define TIMED_FUNCTION(...) TIMED_BLOCK_(DEBUG_NAME(__FUNCTION__), ## __VA_ARGS__)”
GCC expands the macro to
| timed_block TimedBlock_("../cpp/code/handmade_asset.cpp" "|" "31" "|" "2" "|" __FUNCTION__);
|
Problem is that __FUNCTION__ is
declared as a variable and cannot be concatenated with other string literals. I am not sure how to fix this in an elegant way, any ideas?
Clang has another complaint:
“too few arguments provided to function-like macro invocation TIMED_FUNCTION();”
The TIMED_BLOCK_'s “Number” parameter is not set to a value. I guess we want to pass __COUNTER__ here as well
| #define TIMED_FUNCTION(...) TIMED_BLOCK_(DEBUG_NAME(__FUNCTION__), __COUNTER__, ## __VA_ARGS__)
|
And now Clang is happy, but GCC is not:
“expected primary-expression before ')' token #define TIMED_BLOCK__(GUID, Number, ...) timed_block TimedBlock_##Number(GUID, ## __VA_ARGS__)”
GCC now expands the macro to
| timed_block TimedBlock_3("../cpp/code/handmade_asset.cpp" "|" "31" "|" "2" "|" "function",);
|
Note the trailing comma. Shouldn't “##” take care of this? I hate this macro nonsense :(
_snprintf_s is not supported and should be replaced
See
https://hero.handmadedev.org/foru...y-211-gcc-clang-build-report#5277
Cast from void * to GLuint (and vice versa)
“cast from pointer to smaller type 'GLuint' (aka 'unsigned int') loses information”
and the warning
“cast to 'void *' from smaller integer type 'GLuint' (aka 'unsigned int')”
We could use the PointerToU32 macro here and define new one for the other direction
/Kim