1

I have a C++ code section that I want to exclude it from building iOS.

How should I do it?

Follow up question:
If I already have an #ifndef WIN32. I want to combine exclusion of WIN32 with iOS is it possible to do something like #ifndef WIN32 & iOS?
How should I exclude my code from building on Win32 & iOS both in one clause?

PS:
I see a lot of posts explaining how to #ifndef out iOS but how do I combing it with #ifndef WIN32 is the problem.

TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159

1 Answers1

3

To exclude your code from being built on both WIN32 and iOS you need to use #if/#endif instead of #ifndef/#endif. If you have not defined a macro to detect compilation for iOS already, then take a look at this answer. Otherwise, preventing it can be done similarly to this:

#if !defined(WIN32) && !defined(YOUR_IOS_MACRO_HERE)
// Your code here
#endif // !defined(WIN32) && !defined(YOUR_IOS_MACRO_HERE)

The reason you use #if instead of #ifndef is because the former allows multiple statements to be linked with && or ||, whereas the latter only checks the existence of a single macro.

CalPhorus
  • 66
  • 1
  • 6