Predefined Macros
Predefined Macros
Section titled “Predefined Macros”#import <Foundation/Foundation.h>
int main(){ NSLog(@"File :%s\n", __FILE__ ); NSLog(@"Date :%s\n", __DATE__ ); NSLog(@"Time :%s\n", __TIME__ ); NSLog(@"Line :%d\n", __LINE__ ); NSLog(@"ANSI :%d\n", __STDC__ );
return 0;}When the above code in a file main.m is compiled and executed, it produces the following result:
2013-09-14 04:46:14.859 demo[20683] File :main.m2013-09-14 04:46:14.859 demo[20683] Date :Sep 14 20132013-09-14 04:46:14.859 demo[20683] Time :04:46:142013-09-14 04:46:14.859 demo[20683] Line :82013-09-14 04:46:14.859 demo[20683] ANSI :1Syntax
Section titled “Syntax”- DATE The current date as a character literal in “MMM DD YYYY” format
- TIME The current time as a character literal in “HH:MM:SS” format
- FILE This contains the current filename as a string literal.
- LINE This contains the current line number as a decimal constant.
- STDC Defined as 1 when the compiler complies with the ANSI standard.