RAD Studio
ContentsIndex
PreviousUpNext
Macros With Parameters Overview

This section contains Macros With Parameters Overview topics.

Name 
Description 
The following syntax is used to define a macro with parameters:  
The actual_arg_list can contain nested parentheses provided that they are balanced; also, commas appearing within quotes or parentheses are not treated like argument delimiters.  
You can paste (or merge) two tokens together by separating them with ## (plus optional whitespace on either side). The preprocessor removes the whitespace and the ##, combining the separate tokens into one new token. You can use this to construct identifiers.
Given the definition  
The # symbol can be placed in front of a formal macro argument in order to convert the actual argument to a string after replacement.
Given the following definition:  
A long token sequence can straddle a line by using a backslash (\). The backslash and the following newline are both stripped to provide the actual token sequence used in expansions.  
The similarities between function and macro calls often obscure their differences. A macro call has no built-in type checking, so a mismatch between formal and actual argument data types can produce bizarre, hard-to-debug results with no immediate warning. Macro calls can also give rise to unwanted side effects, especially when an actual argument is evaluated more than once.
Compare CUBE and cube in the following example.  
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!