0

I need a constant that clang on mac os x recognizes. I would have though that one of the following would work, but none do.

int main()
{

#ifdef DARWIN
printf(" I am DARWIN\n");
#endif

#ifdef darwin
printf(" I am darwin\n");
#endif

#ifdef MAC
printf(" I am MAC\n");
#endif

#ifdef mac
printf(" I am mac\n");
#endif

#ifdef MACOS
printf(" I am MACOS\n");
#endif

#ifdef macos
printf(" I am macos\n");
#endif

#ifdef MACOSX
printf(" I am MACOSX/n");
#endif

#ifdef macosx
printf(" I am macosx/n");
#endif

}

There must be something that does. This is important for writing portable C programs that work on multiple OS's.

  • https://stackoverflow.com/questions/6802903/c-ifdef-mac-os-x-question – adrtam Feb 14 '19 at 18:32
  • 1
    Execute `clang -E -dM -x c /dev/null` to see the preprocessor symbols defined by the compiler. – Eric Postpischil Feb 14 '19 at 18:33
  • For many compilers and environments: https://sourceforge.net/p/predef/wiki/Home/ . Note that Apple have reverted to using the name MacOS rather than OSX and MacOS is the name used on the site at this link. But the test you need is `__APPLE__ && __MACH__` - Mach being the flavour of Unix that OSX/MacOS is based on. – Clifford Feb 14 '19 at 19:45

0 Answers0