How do I check if one of multiple macros is defined in a single #ifdef?

前端 未结 2 1432
猫巷女王i
猫巷女王i 2020-12-16 14:27

I have some C++ code, and want to perform an action if the __APPLE__ or __linux macros are defined.

If I did it as a normal if

相关标签:
2条回答
  • 2020-12-16 15:05

    In my C++ there is.

    #if defined(__APPLE__) || defined(__linux)
      // ...
    #endif
    
    0 讨论(0)
  • 2020-12-16 15:06

    You can't in a single #ifdef would a single #if do instead?

    #if defined(__APPLE__) || defined(__linux)
    

    this also works if you prefer

    #if defined __APPLE__ || defined __linux
    
    0 讨论(0)
提交回复
热议问题