Alex Rivera | Logout

What C preprocessor conditional should I use for OS X specific code?

Asked 2009-10-07T01:18:34.147
24

What C preprocessor conditional should I use for OS X specific code? I need to include a specific library if I am compiling for OS X or a different header if I am compiling for Linux.

I know there is __APPLE__ but I don't know if that is a current conditional for OS X 10.x.

Edit
Report

1 Answer

42

This list of operating system macros says the presence of both __APPLE__ and __MACH__ indicate OSX.

Also confirmed at line 18 of part of the source for fdisk.

answered 2009-10-07T01:23:03.463

Your Answer