Expected a ";", compilation error with code prover
4 views (last 30 days)
Show older comments
Hello, I'm getting the compilation error expected a ";" in the next lines of one of the header files of my project:
/* ROM CATEGORY 4 START */
VSTD_DEF_CONST(extern, vuint8, CONST) kVStdMainVersion;
VSTD_DEF_CONST(extern, vuint8, CONST) kVStdSubVersion;
VSTD_DEF_CONST(extern, vuint8, CONST) kVStdReleaseVersion;
/* ROM CATEGORY 4 END */
All lines ends with a semicolon, any idea of why is this error appearing and what is the mitigation strategy ?
0 Comments
Accepted Answer
Anirban
on 25 Sep 2019
Edited: Anirban
on 26 Sep 2019
Polyspace Support can help you understand your specific issue. Visit this page. Often, errors like this can indicate some issues in setting up the analysis.
In general, there is one key difference between the code that you see and the code that Polyspace analyzes.
The macros in your code are replaced with their definitions. This is what is called the preprocessed code and emulates what would actually happen at run-time.
Say, you have a file aFile.c that includes a header aFile.h that has this macro definition:
#define FOR_LOOP(n) for(i=0; i<(n); i++);
When analyzing this file, Polyspace includes the content of aFile.h directly in aFile.c, then looks at the macro definitions and replaces all instances of FOR_LOOP() using the above definition. This results in a file aFile.ci, which is the code that Polyspace analyzes.
When you see an error message in a line with a macro, and it seems that the line looks ok, it might mean that replacing the macro with its definition causes the line to be not ok. Looking at the preprocessed code often makes it clear what happened. For instance, the macro definition might itself have a semicolon like in the example above, causing a problem when the replacement is made.
There is a trick to the see the .ci file for each source file. The trick is documented here in context of a different error: https://www.mathworks.com/help/codeprover/ug/conflicting-declarations-in-different-translation-units.html
But since the problem occurs for you in a header file and not in a source file, going down this path might not be a good idea. Often, header files are files that you do not own and even if you find out the exact cause of the error, you might not be able to fix it. The actual fix might be setting an analysis option during setup. For instance, if the header file comes from your compiler, the error might indicate that you have not specified the right compiler version. This is where tech support can help you diagnose your specific issue.
0 Comments
More Answers (1)
rough93
on 25 Sep 2019
Although iirc C++ accepts '/*' as comments, MATLAB only accepts '%', for example:
%this is a comment
/* this is not a comment */
0 Comments
See Also
Categories
Find more on Code Prover Analysis in Polyspace Platform User Interface in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!