#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 个)

Anirban
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
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.

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by