title: How can I check if a cpp file is being compiled in an Objective-C++ project using the preprocessor?
body: <p>I have a C++ source file (.cpp) which is shared between two of my projects, one using Objective-C++ and the other just using plain C++. I have a part of that file where I need to use different code for the Objective-C++ project and for the plain C++ project, so I need to check if the project is being compiled using Objective-C++ or not. After some searching, I found that the <code>__OBJC__</code> macro can be used to check if the file is compiled by an Objective-C compiler, so I tried this code:</p>
  
  <pre><code>#ifdef __OBJC__
      //Objective-C++ specific code here
  #else
      //Plain C++ specific code here
  #endif
  </code></pre>
  
  <p>The problem is that the <code>__OBJC__</code> macro is never defined, not even in the Objective-C++ project. I also noticed that the <code>__OBJC__</code> macro is defined in the .mm files in the Objective-C++ project, but not in the .cpp file.</p>
  
  <p>In case it matters, I'm compiling the Objective-C++ project for iOS with Xcode, and the plain C++ project is a cross-platform computer program which can be compiled using Visual Studio, Xcode or GCC.</p>
  
  <p>How can I check using the preprocessor if my .cpp file is being compiled in an Objective-C++ project or a plain C++ project?</p>