3.4.2 D: Define a Macro
The -Dmacro=text
option allows you to
define preprocessor macros. For macros to be subsequently processed, the source files must
be preprocessed by having them use a .S
file extension or by using the
-xassembler-wth-cpp
option.
A space may be present between the option and macro name.
With no =text
specified in the option, this option defines a
preprocessor macro called macro
that will be considered to have
been defined by any preprocessor directive that checks for such a definition (e.g. the
#ifdef
directive) and that will expand to be the value 1 if it is used
in a context where it will be replaced. For example, when using the option,
-DMY_MACRO
(or -D MY_MACRO
) and supplying the
following code:
#ifdef MY_MACRO
movlw MY_MACRO;
#endif
the movlw
instruction will be assembled and the value
1
will be assigned to the W register.
When the replacement, text
, is specified with the
option, the macro will subsequently expand to be the replacement specified with the option.
So if the above example code was compiled with the option -DMY_MACRO=0x55
,
then the instruction would be assembled as: movlw 0x55
All instances of -D
on the command line are processed
before any -U
options.