-D

Description

Defines the macro name as in a #define preprocessor directive. definition is an optional definition or value assigned to name.

Syntax

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

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.

The configuration file uses the -D option to specify the following predefined macros:

Macro name Applies to AIX v5.2 Applies to AIX v5.1 Applies to AIX v4.3
AIX X X X
AIX32 X X X
AIX41 X X X
AIX43 X X X
AIX50 X X
AIX51 X X
AIX52 X
IBMR2 X X X
POWER X X X
ANSI_C_SOURCE X X X

To ensure that the correct macros for your source file are defined, use the -D option with the appropriate macro name. If your source file includes the /usr/include/sys/stat.h header file, you must compile with the option -D_POSIX_SOURCE to pick up the correct definitions for that file.

If your source file includes the /usr/include/standards.h header file, _ANSI_C_SOURCE, _XOPEN_SOURCE, and _POSIX_SOURCE are defined if you have not defined any of them.

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

Examples

  1. AIX v4.2 and later provides support for files greater than 2 gigabytes in size so you can store large quantities of data in a single file. To allow Large File manipulation in your application, compile with the -D_LARGE_FILES and -qlonglong compiler options. For example:
    xlc myprogram.c -D_LARGE_FILES -qlonglong
  2. 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