A.14.1. Macro Substitution Directive Using #define

When you use the #define macro substitution directive, the C preprocessor (for example, cpp) performs a simple substitution and expands the occurrence of each argument in macro using the replacement-text.

#define macro replacement-text

For example, the macro substitution directive given by

#define RAD 1.2345 

will cause the preprocessor to replace all instances of the variable RAD in your UDF with the number 1.2345. There may be many references to the variable RAD in your function, but you only have to define it once in the macro directive; the preprocessor does the work of performing the substitution throughout your code.

In another example

#define AREA_RECTANGLE(X,Y) ((X)*(Y)) 

all of the references to AREA_RECTANGLE(X,Y) in your UDF are replaced by the product of (X) and (Y).


Release 18.2 - © ANSYS, Inc. All rights reserved.