(Function-like Macros): Explain whitespace around `(' is ok in macro calls.
(Variadic Macros): Delete spurious `;' in some expansion examples.
This commit is contained in:
parent
3b8ad07e1a
commit
d7af004437
15
cpp.texi
15
cpp.texi
|
@ -753,10 +753,21 @@ the macro name. For example,
|
||||||
|
|
||||||
@example
|
@example
|
||||||
#define lang_init() c_init ()
|
#define lang_init() c_init ()
|
||||||
|
lang_init ()
|
||||||
|
@expansion{} c_init ()
|
||||||
|
lang_init ()
|
||||||
|
@expansion{} c_init ()
|
||||||
lang_init()
|
lang_init()
|
||||||
@expansion{} c_init ()
|
@expansion{} c_init ()
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
There must be no space between the macro name and the following
|
||||||
|
open-parenthesis in the the @code{#define} directive; that's what
|
||||||
|
indicates you're defining a function-like macro. However, you can add
|
||||||
|
unnecessary spaces around the open-parenthesis (and around the
|
||||||
|
close-parenthesis) when you @emph{call} the macro; they don't change
|
||||||
|
anything.
|
||||||
|
|
||||||
A function-like macro is expanded only when its name appears with a
|
A function-like macro is expanded only when its name appears with a
|
||||||
pair of parentheses after it. If you write just the name, without
|
pair of parentheses after it. If you write just the name, without
|
||||||
parentheses, it is left alone. This can be useful when you have a
|
parentheses, it is left alone. This can be useful when you have a
|
||||||
|
@ -1171,7 +1182,7 @@ an extra comma in the expansion:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
eprintf ("success!\n")
|
eprintf ("success!\n")
|
||||||
@expansion{} fprintf(stderr, "success!\n", );
|
@expansion{} fprintf(stderr, "success!\n", )
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
|
@ -1192,7 +1203,7 @@ then use the macro @code{eprintf} with empty variable arguments,
|
||||||
|
|
||||||
@example
|
@example
|
||||||
eprintf ("success!\n")
|
eprintf ("success!\n")
|
||||||
@expansion{} fprintf(stderr, "success!\n");
|
@expansion{} fprintf(stderr, "success!\n")
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
|
|
Loading…
Reference in New Issue