Predefined Macros; Standard Predefined Macros - Red Hat ENTERPRISE LINUX 3 - USING CPP Using Instructions

Using cpp, the c preprocessor
Hide thumbs Also See for ENTERPRISE LINUX 3 - USING CPP:
Table of Contents

Advertisement

Chapter 3. Macros
Previous versions of GNU CPP implemented the comma-deletion extension much more generally. We
have restricted it in this release to minimize the differences from C99. To get the same effect with both
this and previous versions of GCC, the token preceding the special
must be white space between that comma and whatever comes immediately before it:
#define eprintf(format, args...) fprintf (stderr, format, ##args)
Refer to Section 11.4 Differences from previous versions for the details.
3.7. Predefined Macros
Several object-like macros are predefined; you use them without supplying their definitions. They fall
into three classes: standard, common, and system-specific.
In C++, there is a fourth category, the named operators. They act like predefined macros, but you
cannot undefine them.
3.7.1. Standard Predefined Macros
The standard predefined macros are specified by the C and/or C++ language standards, so they are
available with all compilers that implement those standards. Older compilers may not provide all of
them. Their names all start with double underscores.
__FILE__
This macro expands to the name of the current input file, in the form of a C string constant. This
is the path by which the preprocessor opened the file, not the short name specified in
or as the input file name argument. For example,
possible expansion of this macro.
__LINE__
This macro expands to the current input line number, in the form of a decimal integer constant.
While we call it a predefined macro, it's a pretty strange macro, since its "definition" changes
with each new line of source code.
and
__FILE__
__LINE__
tected by the program; the message can state the source line at which the inconsistency was detected.
For example,
fprintf (stderr, "Internal error: "
length, __FILE__, __LINE__);
An
directive changes the expansions of
#include
included file. At the end of that file, when processing resumes on the input file that contained the
directive, the expansions of
#include
the
(but
#include
__LINE__
).
#include
A
directive changes
#line
Control.
are useful in generating an error message to report an inconsistency de-
"negative string length "
"%d at %s, line %d.",
__FILE__
is then incremented by one as processing moves to the line after the
, and may change
__LINE__
##
"/usr/local/include/myheader.h"
and
__FILE__
__LINE__
and
revert to the values they had before
__LINE__
as well. Refer to Chapter 6 Line
__FILE__
must be a comma, and there
#include
to correspond to the
21
is a

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents