2024-09-23 04:06 AM
A syntax error is reported against the _Noreturn specified when a function is declared _Noreturn:
_Noreturn void doesNotReturn( void )
{
while ( 1 ) ;
}
The compiler has been configured for C18 and the code compiles.
Can I get this to be accepted by changing a setting, or does this require an update to the Eclipse version used by the IDE?
2024-09-23 04:17 AM
@CTapp.1 wrote:A syntax error is reported against the _Noreturn specified when a function is declared _Noreturn:
Where, exactly, is that error reported - is it a compiler error, or an IDE/editor error?
What happens if you use noreturn (all lowercase) instead?
2024-09-23 05:14 AM
This will work in GCC:
__attribute__((noreturn)) void does_not_return() {
while (1);
}
Or you can use the macros defined in the headers:
__NO_RETURN void does_not_return() {
while (1);
}
2024-09-23 08:07 AM
Sorry, I should have made it clear that this is an IDE error - GCC itself is happy.
noreturn from stdnoreturn get the same reporting.
2024-09-23 08:11 AM
Thanks, they do not result in a syntax error being reported.
Unfortunately, I am writing MISRA compliant code and neither of those are MISRA compliant (use of a language extension) and a deviation is not acceptable as the language provides a compliant alternative.
2024-09-23 08:12 AM - edited 2024-09-23 08:15 AM
Check the code linting settings in Eclipse (codan?)