(Function-like Macros): Explain whitespace around `(' is ok in macro calls.

(Variadic Macros): Delete spurious `;' in some expansion examples.
This commit is contained in:
Richard Stallman 2022-09-18 20:45:22 -04:00
parent 3b8ad07e1a
commit d7af004437
1 changed files with 15 additions and 4 deletions

View File

@ -752,11 +752,22 @@ These are called @dfn{function-like macros}. To define one, use the
the macro name. For example,
@example
#define lang_init() c_init()
#define lang_init() c_init ()
lang_init ()
@expansion{} c_init ()
lang_init ()
@expansion{} c_init ()
lang_init()
@expansion{} c_init()
@expansion{} c_init ()
@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
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
@ -1171,7 +1182,7 @@ an extra comma in the expansion:
@example
eprintf ("success!\n")
@expansion{} fprintf(stderr, "success!\n", );
@expansion{} fprintf(stderr, "success!\n", )
@end example
@noindent
@ -1192,7 +1203,7 @@ then use the macro @code{eprintf} with empty variable arguments,
@example
eprintf ("success!\n")
@expansion{} fprintf(stderr, "success!\n");
@expansion{} fprintf(stderr, "success!\n")
@end example
@noindent