cancel
Showing results for 
Search instead for 
Did you mean: 

CubeIDE incorrectly flags syntax error on static_assert at file scope

CTapp.1
Senior III

Split from CubeIDE incorrectly flags __attribute__((fallthrough)) as syntax error.


I've also noticed it doesn't like the use of static_assert at file scope:

CTapp1_0-1747298533101.png

 

All posts are made in a personal capacity
MISRA C++ Chair
MISRA C WG Member
Director The MISRA Consortium Limited (TMCL)
1 ACCEPTED SOLUTION

Accepted Solutions
Ghofrane GSOURI
ST Employee

Hello @CTapp.1 

Thank you for bringing this issue to our attention.

A ticket has been escalated to dev team for further investigation.

Internal ticket number:209826

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Ghofrane GSOURI
ST Employee

Hello @CTapp.1 

Thank you for bringing this issue to our attention.

A ticket has been escalated to dev team for further investigation.

Internal ticket number:209826

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

FGrie.3
Associate

I have a simple workaround: add

// Next 3 lines prevent bogus error reports in _Static_assert and static_assert
#ifndef __BASE_FILE__ // __BASE_FILE__ known to GCC, not IDT
#define _Static_assert(c,m) typedef int static_assertion[(c)?1:-1]
#endif

That should be early in a .c  file, or in a .h file included early, before #include <assert.h> or anything that does, or any use of _Static_assert or static_assert .

 

I wish the present workaround could be linked to that similar question, which is frozen.

  François Grieu

Better will be :

To ensures that _Static_assert is recognized properly by the IDE during indexer parsing.

In Project → Properties → C/C++ General → Preprocessor Include Paths, Macros, etc.:

Go to the Providers tab and make sure CDT User Setting Entries is checked.

Then, switch to the Entries tab → expand GNU C under CDT User Setting Entries, and add the following macro:

_Static_assert(a,b)