|
987 | 987 | There shall be whitespace between the identifier and the replacement list
|
988 | 988 | in the definition of an object-like macro.
|
989 | 989 |
|
990 |
| -\pnum |
991 |
| -If the \grammarterm{identifier-list} in the macro definition does not end with |
992 |
| -an ellipsis, the number of arguments (including those arguments consisting |
993 |
| -of no preprocessing tokens) |
994 |
| -in an invocation of a function-like macro shall |
995 |
| -equal the number of parameters in the macro definition. |
996 |
| -Otherwise, there shall be at least as many arguments in the invocation as there are |
997 |
| -parameters in the macro definition (excluding the \tcode{...}). There |
998 |
| -shall exist a |
999 |
| -\tcode{)} |
1000 |
| -preprocessing token that terminates the invocation. |
1001 |
| - |
1002 | 990 | \pnum
|
1003 | 991 | \indextext{__va_args__@\mname{VA_ARGS}}%
|
1004 | 992 | \indextext{__va_opt__@\mname{VA_OPT}}%
|
|
1068 | 1056 | \end{codeblock}
|
1069 | 1057 | \end{example}
|
1070 | 1058 |
|
| 1059 | +\begin{bnf} |
| 1060 | +\nontermdef{pp-balanced-token}\br |
| 1061 | + \textnormal{any} preprocessing-token \textnormal{other than \terminal{(} or \terminal{)}}\br |
| 1062 | + \terminal{(} \opt{pp-balanced-token-seq} \terminal{)} |
| 1063 | +\end{bnf} |
| 1064 | + |
| 1065 | +\begin{bnf} |
| 1066 | +\nontermdef{pp-balanced-token-seq}\br |
| 1067 | + pp-balanced-token\br |
| 1068 | + pp-balanced-token pp-balanced-token-seq |
| 1069 | +\end{bnf} |
| 1070 | + |
1071 | 1071 | \pnum
|
1072 | 1072 | A preprocessing directive of the form
|
1073 | 1073 | \begin{ncsimplebnf}
|
|
1081 | 1081 | The parameters
|
1082 | 1082 | \indextext{parameter!macro}%
|
1083 | 1083 | are specified by the optional list of identifiers.
|
1084 |
| -Each subsequent instance of the function-like macro name followed by a |
1085 |
| -\tcode{(} |
1086 |
| -as the next preprocessing token |
1087 |
| -introduces the sequence of preprocessing tokens that is replaced |
1088 |
| -by the replacement list in the definition |
1089 |
| -(an invocation of the macro). |
1090 |
| -\indextext{invocation!macro}% |
1091 |
| -The replaced sequence of preprocessing tokens is terminated by the matching |
1092 |
| -\tcode{)} |
1093 |
| -preprocessing token, skipping intervening matched pairs of left and |
1094 |
| -right parenthesis preprocessing tokens. |
1095 |
| -Within the sequence of preprocessing tokens making up an invocation |
1096 |
| -of a function-like macro, |
1097 |
| -new-line is considered a normal whitespace character. |
1098 | 1084 |
|
1099 | 1085 | \pnum
|
| 1086 | +\indextext{invocation!macro}% |
1100 | 1087 | \indextext{macro!function-like!arguments}%
|
1101 |
| -The sequence of preprocessing tokens |
1102 |
| -bounded by the outside-most matching parentheses |
1103 |
| -forms the list of arguments for the function-like macro. |
1104 |
| -The individual arguments within the list |
1105 |
| -are separated by comma preprocessing tokens, |
1106 |
| -but comma preprocessing tokens between matching |
1107 |
| -inner parentheses do not separate arguments. |
1108 |
| -If there are sequences of preprocessing tokens within the list of |
1109 |
| -arguments that would otherwise act as preprocessing directives, |
| 1088 | +Each instance of a function-like macro name |
| 1089 | +followed by a \tcode{(} as the next preprocessing token |
| 1090 | +shall be a function-like macro invocation of the form: |
| 1091 | +\begin{ncsimplebnf} |
| 1092 | +identifier \terminal{(} \opt{pp-balanced-token-seq} \terminal{)} |
| 1093 | +\end{ncsimplebnf} |
| 1094 | +Within the sequence of preprocessing tokens |
| 1095 | +making up an invocation of a function-like macro, |
| 1096 | +new-line is considered a normal whitespace character. |
| 1097 | +The arguments of the macro invocation are |
| 1098 | +the sequences of \grammarterm{pp-balanced-token}s |
| 1099 | +separated by comma preprocessing tokens. |
| 1100 | +If the \grammarterm{identifier-list} in the macro definition |
| 1101 | +does not end with an ellipsis, |
| 1102 | +the number of arguments |
| 1103 | +(including those arguments consisting of no \grammarterm{pp-balanced-token}s) |
| 1104 | +shall equal the number of parameters in the macro definition. |
| 1105 | +Otherwise, there shall be at least as many arguments in the invocation |
| 1106 | +as there are parameters in the macro definition (excluding the \tcode{...}). |
| 1107 | +If there are sequences of preprocessing tokens within the list of arguments |
| 1108 | +that would otherwise act as preprocessing directives, |
1110 | 1109 | \begin{footnote}
|
1111 |
| -A \grammarterm{conditionally-supported-directive} is a preprocessing directive regardless of whether the implementation supports it. |
| 1110 | +A \grammarterm{conditionally-supported-directive} is a preprocessing directive |
| 1111 | +regardless of whether the implementation supports it. |
1112 | 1112 | \end{footnote}
|
1113 | 1113 | the behavior is undefined.
|
1114 | 1114 |
|
| 1115 | +\pnum |
| 1116 | +\indextext{macro!function-like!arguments}% |
| 1117 | +If there is a \tcode{...} immediately preceding the \tcode{)} in the |
| 1118 | +function-like macro |
| 1119 | +definition, then the trailing arguments (if any), including any separating comma preprocessing |
| 1120 | +tokens, are merged to form a single item: the \defn{variable arguments}. The number of |
| 1121 | +arguments so combined is such that, following merger, the number of arguments is |
| 1122 | +either equal to or |
| 1123 | +one more than the number of parameters in the macro definition (excluding the |
| 1124 | +\tcode{...}). |
| 1125 | + |
| 1126 | +\pnum |
| 1127 | +Each function-like macro invocation |
| 1128 | +is replaced by the replacement list in the macro definition, |
| 1129 | +after performing argument substitution as described in \ref{cpp.subst}. |
| 1130 | + |
1115 | 1131 | \pnum
|
1116 | 1132 | \begin{example}
|
1117 | 1133 | The following defines a function-like
|
|
1133 | 1149 | the resulting expression are bound properly.
|
1134 | 1150 | \end{example}
|
1135 | 1151 |
|
1136 |
| -\pnum |
1137 |
| -\indextext{macro!function-like!arguments}% |
1138 |
| -If there is a \tcode{...} immediately preceding the \tcode{)} in the |
1139 |
| -function-like macro |
1140 |
| -definition, then the trailing arguments (if any), including any separating comma preprocessing |
1141 |
| -tokens, are merged to form a single item: the \defn{variable arguments}. The number of |
1142 |
| -arguments so combined is such that, following merger, the number of arguments is |
1143 |
| -either equal to or |
1144 |
| -one more than the number of parameters in the macro definition (excluding the |
1145 |
| -\tcode{...}). |
1146 |
| - |
1147 | 1152 | \rSec2[cpp.subst]{Argument substitution}%
|
1148 | 1153 | \indextext{macro!argument substitution}%
|
1149 | 1154 | \indextext{argument substitution|see{macro, argument substitution}}%
|
1150 | 1155 |
|
1151 | 1156 | \indextext{__va_opt__@\mname{VA_OPT}}%
|
1152 | 1157 | \begin{bnf}
|
1153 | 1158 | \nontermdef{va-opt-replacement}\br
|
1154 |
| - \terminal{\mname{VA_OPT} (} \opt{pp-tokens} \terminal{)} |
| 1159 | + \terminal{\mname{VA_OPT} (} \opt{pp-balanced-token-seq} \terminal{)} |
1155 | 1160 | \end{bnf}
|
1156 | 1161 |
|
1157 | 1162 | \pnum
|
|
0 commit comments