#error directive: "Header is not supported in the C89 language mode"
8 次查看(过去 30 天)
显示 更早的评论
I am using #error directives in my code but unfortunately polyspace analysis is throwing an error
error: #error directive: "Header is not supported in the C89 language mode"
| #error "Header is not supported in the C89 language mode"
| ^
I tried -no-language-extensions by removing compiler = iar option, but it still didnt solve the issue. Is there any other way this could be solved ?
I am using MATLAB R2017b
1 个评论
Walter Roberson
2022-2-25
That does seem a bit odd, as the 1990 ("C89") standard 6.8.5 defines #error
回答(1 个)
Anirban
2022-3-10
When a compiler encounters a #error directive, it stops and prints the associated message. Polyspace behaves exactly like a compiler in this respect and does the same thing.
I am guessing, in this case, your code compiles with your compiler but not with Polyspace. This probably means that you have not fully emulated your compiler with the Polyspace analysis options. For instance, you might not have set the right value of -compiler or might be using specific compiler options when compiling (that Polyspace is not aware of). For more details, see Fix Polyspace Compilation Errors Related to #error Directive.
To be able to help you more with this specific error message, you have to give us the code around the #error directive. As you will see in the documentation link above, a #error directive is typically inside some kind of #ifdef guard. It would be interesting to see that guard and how Polyspace was able to get through the guard, but your compiler didn't.
1 个评论
Walter Roberson
2022-3-10
Ah, I just realized that the compiler options that Polyspace was told, are such that it is bringing in a #include that does not belong in C89 mode. However, at the moment it is not entirely clear whether C89 mode was the intended compilation environment.
另请参阅
类别
在 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!