-D

Description

Defines the macro name as in a #define preprocessor directive.

Syntax

Read syntax diagramSkip visual syntax diagram>>- -D--name--+-------------------+----------------------------><
              '-=--+------------+-'
                   '-definition-'
 

definition is an optional definition or value assigned to name.

Notes

You can also define a macro name in your source program using the #define preprocessor directive, provided that the macro name has not already been defined by the -D compiler option.

-Dname= is equivalent to #define name.

-Dname is equivalent to #define name 1. (This is the default.)

Using the #define directive to define a macro name already defined by the -D option will result in an error condition.

To aid in program portability and standards compliance, the operating system provides several header files that refer to macro names you can set with the -D option. You can find most of these header files either in the /usr/include directory or in the /usr/include/sys directory.

To ensure that the correct macros for your source file are defined, use the -D option with the appropriate macro name.

The -Uname option, which is used to undefine macros defined by the -D option, has a higher precedence than the -Dname option.

Example

  1. To specify that all instances of the name COUNT be replaced by 100 in myprogram.c, enter:
    xlc myprogram.c -DCOUNT=100
    This is equivalent to having #define COUNT 100 at the beginning of the source file.

Related information