0

In my Prefix.pch file I am using __OBJC__ preprocessor define for compilation of Objective C headers. What is the equivalent for compilation of C++ headers?

#ifdef __OBJC__
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
#endif

1 Answer 1

2

There is a standard preprocessor constant, __cplusplus. Its value is expanded to version number of C++ standard being used:

__cplusplus

denotes the version of C++ standard that is being used, expands to value 199711L (until C++11), 201103L (C++11), 201402L (C++14), or 201703L (C++17)

Source: cppreference

So, you can write, for example:

#ifdef __cplusplus
  #if __cplusplus >= 201103L
    // include new stuff
  #else
    // use legacy features
  #endif
#endif
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.