cancel
Showing results for 
Search instead for 
Did you mean: 

_Noreturn is reported as a syntax error

CTapp.1
Senior

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?

5 REPLIES 5

@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?

https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Function-Attributes.html#:~:text=len)%0A%20%20%20%20%20%20%20%20%20%20%09__attribute__((nonnull))%3B-,noreturn,-A%20few%20standard

 

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);
}

 

If you feel a post has answered your question, please click "Accept as Solution".

Sorry, I should have made it clear that this is an IDE error - GCC itself is happy.

CTapp1_0-1727103999331.png

noreturn from stdnoreturn get the same reporting.

 

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.

Pavel A.
Evangelist III

Check the code linting settings in Eclipse (codan?)