Monday, 7 November 2011

What are the standard predefined macros? in C programming

What are the standard predefined macros?

The ANSI C standard defines six predefined macros for use in the C language:
-----------------------------------------------------------------------------------------------------------
Macro Name                                         Purpose
------------------------------------------------------------------------------------------------------------
_ _LINE_ _                                           nserts the current source code line number in your code.
_ _FILE_ _                                           Inserts the current source code filename in your code.
_ _DATE_ _                                          Inserts the current date of compilation in your code.
_ _TIME_ _                                          Inserts the current time of compilation in your code.
_ _STDC_ _                                          Is set to 1 if you are enforcing strict ANSI C conformity.
_ _cplusplus                                           Is defined if you are compiling a C++ program.
-------------------------------------------------------------------------------------------------------------
The _ _LINE_ _ and _ _FILE_ _ symbols are commonly used for debugging purposes (see FAQs V.19 and
V.20). The _ _DATE_ _ and _ _TIME_ _ symbols are commonly used to put a time stamp on your compiled
program for version tracking purposes (see FAQ V.28). The _ _STDC_ _ symbol is set to 1 only if you are
forcing your compiler to conform to strict ANSI C standards (see FAQ V.30). The _ _cplusplus symbol is
defined only when you are compiling your program using the C++ compiler (see FAQ V.21).

Cross Reference:

V.1: What is a macro, and how do you use it?
V.24: What is the _ _FILE_ _ preprocessor command?
V.26: What is the _ _LINE_ _ preprocessor command?
V.28: What are the _ _DATE_ _ and _ _TIME_ _ preprocessor commands?

No comments:

Post a Comment