![]() ![]() The arguments (called variable arguments) can be accessed only with _VA_ARGS_ identifier, which is then replaced with arguments, supplied with the identifier to be replaced.įor versions (3,4), replacement-list may contain the token sequence _VA_OPT_( content ), which is replaced by content if _VA_ARGS_ is non-empty, and expands to nothing otherwise. Version (4) of the #define directive defines a function-like macro with variable number of arguments, but no regular arguments. The additional arguments (called variable arguments) can be accessed using _VA_ARGS_ identifier, which is then replaced with arguments, supplied with the identifier to be replaced. Version (3) of the #define directive defines a function-like macro with variable number of arguments. Version (2) of the #define directive defines a simple function-like macro. does not have parentheses after itself, it is not replaced at all. If the identifier is not in functional-notation, i.e. For versions (3,4), the number of arguments must not be less than the number of parameters ( not (since C++20) counting. The sequence is terminated by the matching ) token, skipping intervening matched pairs of left and right parentheses.įor version (2), the number of arguments must be the same as the number of parameters in macro definition. The syntax of a function-like macro invocation is similar to the syntax of a function call: each instance of the macro name followed by a ( as the next preprocessing token introduces the sequence of tokens that is replaced by the replacement-list. Version (1) of the #define directive behaves exactly like that.įunction-like macros replace each occurrence of defined identifier with replacement-list, additionally taking a number of arguments, which then replace corresponding occurrences of any of the parameters in the replacement-list. ![]() ![]() Object-like macros replace every occurrence of defined identifier with replacement-list. If the identifier is already defined as any type of macro, the program is ill-formed unless the definitions are identical. Exceptions arise from the rules of scanning and replacement. The #define directives define the identifier as macro, that is instruct the compiler to replace most successive occurrences of identifier with replacement-list, which will be additionally processed. #define identifier (.) replacement-list (optional) #define identifier ( parameters ) replacement-list (optional) #define identifier replacement-list (optional) ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |