Expected a ";", compilation error with code prover
조회 수: 8 (최근 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!