Expected a ";", compilation error with code prover
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Anirban
2019-9-25
编辑:Anirban
2019-9-26
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 个评论
更多回答(1 个)
rough93
2019-9-25
Although iirc C++ accepts '/*' as comments, MATLAB only accepts '%', for example:
%this is a comment
/* this is not a comment */
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Troubleshoot Compilation Errors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!