Browse Source

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

(Variadic Macros): Delete spurious `;' in some expansion examples.
Richard Stallman 2 years ago
parent
commit
d7af004437
1 changed files with 15 additions and 4 deletions
  1. 15 4
      cpp.texi

+ 15 - 4
cpp.texi

@@ -752,11 +752,22 @@ These are called @dfn{function-like macros}.  To define one, use the
 the macro name.  For example,
 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