Fix Polyspace Compilation Errors Related to Generic Compiler
If you use a generic compiler, you can encounter this issue. For more information, see Compilation toolchain (Static analysis).
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 Compilation toolchain (Static analysis).
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 modeling, remove it from the preprocessed code. For instance, to remove the
datakeyword, enterdata=for the optionPreprocessor definitions (-D).If the keyword is related to an attribute, remove attributes from the preprocessed code. Enter
__attribute__(x)=for the optionPreprocessor definitions (-D).If your code has this line:
And you remove attributes, the analysis reads the line as:void __attribute__ ((weak)) func(void);
void func(void);
When you use these workarounds, your source code is not altered.