Is it possible to print the preprocessor value in a message / warning in Xcode?

I want to print (at compile time) messages telling me about some preprocessor settings in an Xcode5 C ++ project. I believe that there is no standard way to do this (I have done this using tricks in VC ++ before).

How can I get this code to print the actual value __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__?

#   if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 60000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
#       define OGRE_PLATFORM OGRE_PLATFORM_APPLE_IOS
#   else
#       define OGRE_PLATFORM OGRE_PLATFORM_APPLE
#   endif
+4
source share
1 answer

This worked for me:

#define STR(X) #X
#define DEFER(M,...) M(__VA_ARGS__)
#pragma message "min version required is " DEFER(STR,__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)

Hat tip (and link link) in the Clang User Guide .

+3
source

Source: https://habr.com/ru/post/1530022/


All Articles