UpstandingHackers / hammer

Parser combinators for binary formats, in C. Yes, in C. What? Don't look at me like that.
GNU General Public License v2.0
430 stars 40 forks source link

macOS build failure (and fix) #191

Closed c-alpha closed 4 years ago

c-alpha commented 5 years ago

On macOS, using the clang bundled with Xcode, the build fails:

clang -o build/opt/src/backends/regex.os -c -std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -Wno-unused-variable -O3 -fPIC build/opt/src/backends/regex.c
build/opt/src/backends/regex.c:229:32: error: unknown warning group '-Wclobbered', ignored [-Werror,-Wunknown-warning-option]
#pragma GCC diagnostic ignored "-Wclobbered"
                               ^
1 error generated.
scons: *** [build/opt/src/backends/regex.os] Error 1
scons: building terminated because of errors.

This is because we're using clang "in GCC mode" by specifying -std=gnu99, but of course it's not the real McCoy, and thus the #pragma makes clang barf.

The solution is to check whether the compiler is clang inside the #idef __GCC__. This may seem counter-intuitive, but actually is logical (and works). The change felt a bit slim for a PR, so I'm including a patch with this issue.

Wclobbered.patch.zip

pesco commented 4 years ago

I believe I independently fixed this with #192