Rate This Document
Findability
Accuracy
Completeness
Readability

-fmacro-use-commandline

Description

Macros in the command line are preferentially used.

Usage

Add the compilation option -fmacro-use-commandline, and append the -D macro definition to it. For example, -fmacro-use-commandline -DTEST_MACRO=222 defines the DTEST_MACRO macro as 222.

Result

The test case is as follows:

1
2
3
4
5
6
7
#define TEST_MACRO 10
 
int main()
{
    printf("Hello World, TEST_MACRO:%d\n", TEST_MACRO);
    return 0;
}

Test command:

1
gcc -E test.c -o test.i -fmacro-use-commandline -DTEST_MACRO=222
Figure 1 Option disabled
Figure 2 Option enabled

After the option is enabled, the macro definition in the command line is preferentially used, defining the TEST_MACRO macro as 222.