Borrar filtros
Borrar filtros

#error directive: "Header is not supported in the C89 language mode"

6 visualizaciones (últimos 30 días)
Sudarshan Madhavan
Sudarshan Madhavan el 25 de Feb. de 2022
Comentada: Walter Roberson el 10 de Mzo. de 2022
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

Respuestas (1)

Anirban
Anirban el 10 de Mzo. de 2022
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 comentario
Walter Roberson
Walter Roberson el 10 de Mzo. de 2022
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.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by