Main Content

Fix Polyspace Compilation Errors Related to Generic Compiler

If you use a generic compiler, you can encounter this issue. For more information, see Compiler (-compiler).

Issue

The analysis stops with an error message related to a non-ANSI® C keyword, for instance, data or attributes such as __attribute__((weak)).

Depending on the location of the keyword, the error message can vary. For instance, this line causes the error message: expected a ";".

data int tab[10];

Cause

The generic Polyspace® compiler supports only ANSI C keywords. If you use a language extension, the generic compiler does not recognize it and treats the keyword as a regular identifier.

Solution

Specify your compiler by using the option Compiler (-compiler).

If your compiler is not directly supported or is not based on a supported compiler, you can use the generic compiler. To work around the compilation errors:

  • If the keyword is related to memory modelling, remove it from the preprocessed code. For instance, to remove the data keyword, enter data= for the option Preprocessor definitions (-D).

  • If the keyword is related to an attribute, remove attributes from the preprocessed code. Enter __attribute__(x)= for the option Preprocessor definitions (-D).

    If your code has this line:

    void __attribute__ ((weak)) func(void);
    And you remove attributes, the analysis reads the line as:
    void func(void);

When you use these workarounds, your source code is not altered.