__APPLE__ : Defined for an Apple Platform, such as OS X.
__APPLE_CC__ : This is an integer value representing the version of the compiler.
__OBJC__ : Defined if the compiler is compiling in Objective-C mode
__cplusplus : Defined if the compiler is compiling in C++ mode.
__MACH__ : Defined if the Mach system calls are available
__DATE__ : The current date
__TIME__ : The current time
__FILE__ : The name of file
__LINE__ : The line number of the file
__FUNCTION__ : The name of the function r Objective-C method being compiled
// predef.m -- play with predefined macros
/* compile with
cc -g -Wall -o predef -framework Foundation predef.m
*/
#import
#import
void someFunc (void)
{
printf ("file %s, line %d, function %s\n", __FILE__, __LINE__, __FUNCTION__);
} // someFunc
@interface SomeClass : NSObject { }
+ (void) someMethod;
@end
@implementation SomeClass
+ (void) someMethod
{
printf ("file %s, line %d, function %s\n", __FILE__, __LINE__, __FUNCTION__);
} // someMethod
@end
int main (int argc, char *argv[])
{
printf ("__APPLE__: %d, __APPLE_CC__: %d\n",
__APPLE__, __APPLE_CC__);
printf ("today is %s, the time is %s\n", __DATE__, __TIME__);
printf ("file %s, line %d, function %s\n", __FILE__, __LINE__, __FUNCTION__);
someFunc ();
[SomeClass someMethod];
return (0);
} // main
cc -g -Wall -o predef -framework Foundation predef.m
./predef
__APPLE__: 1, __APPLE_CC__: 5657
today is Feb 1 2010, the time is 12:32:23
file predef.m, line 32, function main
file predef.m, line 13, function someFunc
file predef.m, line 23, function +[SomeClass someMethod]