Menu ▾ ▴

SyntaxCheckCompilerFlag

Brad Lanam

Wiki Home
Syntax
Checks

.check_compile_flag

Checks to see if a compiler flag is valid, and if so, adds it to CFLAGS for the current profile.

.check_compile_flag '-Wmissing-prototypes';
.check_compile_flag '-Wno-missing-prototypes' { .negate; }

Because gcc will not create a warning or error when a compiler flag is prefixed with '-Wno-', it is necessary to check the compiler flag without the '-Wno-' prefix. To do this, append a statement block to the check, and add the .negate attribute.

But be aware that some warning flags such as '-Wno-poison-system-directories' for MacOS/clang do not have an opposite and cannot be tested with the .negate attribute.

Generated Name: Prefix: cf_
The leading '-' or '-W' is removed from the name.
Example: cf_missing_prototypes

Adding a Compiler Flag
.add_compile_flag '-DNO_DEPRECATED';

Adds a compiler flag without any validation.

Examples
.check_compile_flag '-Wall';
.check_compile_flag '-Wformat';
Attributes

Wiki Home
Syntax
Checks


Related

Wiki: Home
Wiki: Syntax
Wiki: SyntaxAttrCompileFlag
Wiki: SyntaxAttrHeader
Wiki: SyntaxAttrName
Wiki: SyntaxCheck