| Syntax: | Default: |
| define(macro_name[, string]) | none |
This option defines preprocessor macros that can be used in the associated source files or source groups. By default, only the VisualAge C++ predefined macros and ANSI/ISO predefined macros are defined.
Use this option to define macros without having to modify sources, or to provide macros that apply in some circumstances but should not be defined at other times.
The first argument of the define option names the macro. The second argument is the replacement list of preprocessor tokens to be assigned to the macro. If you do not supply a string, the macro has the default definition, "1". You can specify "" to define a macro for the null string. If the replacement string is more than one word, delimit it with double quotes, as in the following example:
define(MYMACRO, "a b c")
Use the \ character as an escape character if the replacement string contains string literal or a reserved character, such as \. For example, \" represents a " (double quote) and \\ represents a \ (backslash). In the example below, the MY_DIR macro is give the value of "c:\mydir". Note that in this example the replacement string includes the double quotes on each end of the string.
define(MY_DIR, "\"C:\\MYDIR\"")
If you specify the define option more than once with the same macro name, the last definition overrides previous replacement strings for the macro.
The macro is defined for all source files to which this option applies. Macros defined with this option are local to the source files, even if macros(global) also applies to the sources. For example, the following lines define ERA to be the constant 100 in a.cpp and c.cpp, and 1000 in b.cpp:
option macros(global), define(ERA, 100) {
source "a.cpp"
option define(ERA, 1000) {
source "b.cpp"
}
source "c.cpp"
}
A macro named by the define option takes effect at the beginning of the source, and remains in effect until the end of the source or until the macro is undefined or redefined within the source. While it is in effect, the definition from the define option hides other visible definitions of the same macro. At the end of the source, the previous definition is restored. However, if the macro is undefined or redefined in the source, the change in definition remains in effect.
You can undefine a macro with undefine(macro_name).
![]()
Incremental C++ Builds
C Compilation
Macros in C++ Source Files
![]()
Miscellaneous Build Options
![]()
Miscellaneous Build Options
