ANSI Predefined Symbols

Table 1 lists the symbols required by the ANSI/ISO C standard.

Table 1. ANSI Predefined Symbols
This symbol… is…
__DATE__ The date the file is compiled; for example, "Jul 14, 1995". This symbol is a predefined macro.
__FILE__ The name of the file being compiled; for example "prog.c". This symbol is a predefined macro.
__func__ The name of the function currently being compiled. This predefined identifier is only available under the emerging ANSI/ISO C99 standard.
__LINE__ The number of the line being compiled (before including any header files). This symbol is a predefined macro.
__TIME__ The time the file is compiled in 24-hour format; for example, "13:01:45". This symbol is a predefined macro.
__STDC__ Defined as 1 if compiling C source code; undefined when compiling C++ source code. This macro lets you know that Carbide C implements the ANSI C standard.
Listing 1 shows a small program that uses the ANSI predefined symbols.

Listing 1. Using ANSI Predefined Symbols
#include <stdio.h>

void main(void)
{
printf("Hello World!\n");

printf("%s, %s\n", __DATE__, __TIME__);
printf("%s, line: %d\n", __FILE__, __LINE__);
}

/* The program prints something like the following:
Hello World!
Oct 31 2005, 18:53:50
main.ANSI.c, line: 10
*/