Main Content

Disabled preprocessor definitions (-U)

Undefine macros in preprocessed code

Description

Undefine macros in preprocessed code.

Set Option

User interface (desktop products only): In your project configuration, the option is on the Macros node.

User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Build tab on the Target & Compiler node.

Command line and options file: Use the option -U. See Command-Line Information.

Why Use This Option

Use this option to emulate your compiler behavior. For instance, your compiler might consider a macro _WIN32 as undefined and execute the code in a #ifndef _WIN32 block. To emulate this behavior when running a Polyspace® analysis, use this option to specify _WIN32 as undefined.

This option undefines these macros:

If you define a macro by using a #define statement in your source code, this option cannot undefine it.

Typically, you recognize from compilation errors that a certain macro must be undefined. For instance, the following code does not compile if the macro _WIN32 is defined.

#ifndef _WIN32
  int env_var;
#endif

void set() {
  env_var=1;
}
The error message states that env_var is undefined. However, the definition of env_var is in the #ifndef _WIN32 statement. The underlying cause for the error is that the macro _WIN32 is defined. You must undefine _WIN32.

Settings

No Default

Using the button, add a new row for each macro being undefined.

Tips

Your compiler specification determines the values of many compiler-specific macros. In case you want to know how Polyspace defines a specific macro, use the option -dump-preprocessing-info.

  • To override a macro definition coming from a compiler specification, use the option Preprocessor definitions (-D).

  • To undefine the macro, use this option.

During the build process, file-specific undefines are merged with project level build configurations. Using this option with a CMAKE-based toolchain results in a warning.

Command-Line Information

You can specify only one flag with each -U option. However, you can specify the option multiple times.

Parameter: -U
No Default
Value: macro
Example (Bug Finder): polyspace-bug-finder -U HAVE_MYLIB -U USE_COM1
Example (Code Prover): polyspace-code-prover -U HAVE_MYLIB -U USE_COM1
Example (Bug Finder Server): polyspace-bug-finder-server -U HAVE_MYLIB -U USE_COM1
Example (Code Prover Server): polyspace-code-prover-server -U HAVE_MYLIB -U USE_COM1