Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I print out a preprocessor value in a message/warning in Xcode?

I want to print out (during compilation) messages telling me about some preprocessor settings in an Xcode5 C++ project. I believe there is no standard way of doing this (I've done it using tricks in VC++ before).

How can I make this code print out the actual value of __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
like image 397
Mr. Boy Avatar asked Oct 20 '22 13:10

Mr. Boy


1 Answers

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 reference link) to the Clang User Manual.

like image 124
Clay Bridges Avatar answered Oct 30 '22 02:10

Clay Bridges