Is the C preprocessor for Mac OSX not working with Mojave correctly, or am I making some dumb mistake? The code below compiles but will not print "test" to the console.
According to https://sourceforge.net/p/predef/wiki/OperatingSystems/ and multiple Stack Overflow posts I have looked at __APPLE__
should do the trick. I've also tried __MACH__
and using __APPLE__ && __MACH__
but this does not work either.
I'm compiling in terminal via gcc.
Is it possible that these don't work with the newest version of OSX as it was only released a few weeks ago? I never had this problem until I updated to Mojave.
I've also tried calling a function in place of printf("test");
but the results are the same.
#include <stdio.h>
int main()
{
#ifdef __APPLE__
printf("test");
#endif
return 0;
}
Reinstalling GCC seems to have resolved the issue. #define __APPLE__ 1
was missing from gcc when I ran gcc -dM -E - < /dev/null
in terminal. It has returned upon reinstall. Possible corruption from upgrading.