As mentioned in the wiki, in root / trunk / Source / JavaScriptCore / wtf / Platform.h we get a definition for each of these defines. For example, the PLATFORM macro is defined as:
#define PLATFORM(WTF_FEATURE) \ (defined WTF_PLATFORM_##WTF_FEATURE \ && WTF_PLATFORM_##WTF_FEATURE)
The value of WTF_FEATURE will be replaced by the platform name to create a macro called WTF_PLATFORM_WTF_FEATRE . For example, if WTF_FEATURE passed to the macro as a MAC , you will get the extension WTF_PLATFORM_MAC . The defined preprocessor directive, combined with a logical AND , basically asks if this macro value is defined and if it is defined if its value is a "true" value. You should use this macro somewhere else in the preprocess, for example:
#ifdef __APPLE__ #define WTF_PLATFORM_MAC 1 #end if #define PLATFORM(WTF_FEATURE) \ (defined WTF_PLATFORM_##WTF_FEATURE \ && WTF_PLATFORM_##WTF_FEATURE) #if PLATFORM(MAC)
You would not use it in C ++ code, for example
if (PLATFORM(MAC)) {
which will cause a bunch of errors from the compiler, since defined not a C ++ keyword, and evaluating and replacing a macro in C ++ code will ultimately reset the pre-processor defined directive to any C ++ code that is directly called a macro. This is invalid C ++.
Thanks to Johannes for pointing out some of these issues.
Jason source share