[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


ANSI Predefined Symbols

The table below lists the symbols that the ANSI C standard requires.

ANSI predefined symbols:

This macro
is
__DATE__  
The date at which the file is compiled; for example, "Jul 14, 1995".  
__FILE__  
The name of the file being compiled; for example "prog.c".  
__func__  
The name of the function currently being compiled. This predefined symbol is only available under the emerging ANSI/ISO C9X standard.  
__LINE__  
The line number of the line being compiled. This is the number before including any header files.  
__TIME__  
The time at which the file is compiled in 24-hour format; for example, "13:01:45".  
__STDC__  
Defined as 1 if compiling C source code. This macro lets you know that Metrowerks C implements the ANSI C standard. This macro is undefined when compiling C++ source code.  

Listing 7.1 shows a small program that uses the ANSI predefined symbols.

Using ANSI's 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 1995, 18:23:50
main.ANSI.c, line: 10


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 17, 2000