If there’s some cross-platform C/C++ code that should be compiled on Mac OS X, iOS, Linux, Windows, how can I detect them reliably during preprocessor process?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are predefined macros that are used by most compilers, you can find the list here. GCC compiler predefined macros can be found here.
Here is an example for gcc:
The defined macros depend on the compiler that you are going to use.
The
_WIN64#ifdefcan be nested into the_WIN32#ifdefbecause_WIN32is even defined when targeting the Windows x64 version. This prevents code duplication if some header includes are common to both(also
WIN32without underscore allows IDE to highlight the right partition of code).