1

Should i use __APPLE__ & __MACH__ or __APPLE__ for my preprocessors?

I found about the __APPLE__ here: How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor?

and here http://sourceforge.net/apps/mediawiki/predef/index.php?title=Operating_Systems#MacOS about the __APPLE__&__MACH__

I'm not sure about what should i use.

Community
  • 1
  • 1
ghaschel
  • 1,313
  • 3
  • 20
  • 41

2 Answers2

2

I think the sourceforge documentation means that you can use either __APPLE__ or __MACH__.

tomahh
  • 13,441
  • 3
  • 49
  • 70
1

Both macros are defined (on Mac OS X or iOS):

cc -E -dM - < /dev/null | egrep "APPLE|MACH"
#define __APPLE__ 1
#define __MACH__ 1

To me that's fine to stick with if defined(__MACH__) && defined(__APPLE__) as pointed out by http://sourceforge.net/apps/mediawiki/predef/index.php?title=Operating_Systems#MacOS

deltheil
  • 15,496
  • 2
  • 44
  • 64