2025-10-14 7:31 AM - last edited on 2025-10-14 7:56 AM by Andrew Neil
Defining the underlying type of an enumeration has been a difficult task until C23 added the feature. Previously different compilers used different methods and results could vary unexpectedly.
As seen in the image below, STM32CubeIDE v 1.19.0 can recognize this C23 feature and flag mistakes, such as the out-of-range value 0x101 for the 8-bit enum.
As seen in the gcc output below, the mistake is caught by gcc:
This is all as it should be. The problem is when I remove the fake out-of-range command, gcc works as expected but STM32CubeIDE flags a syntax error:
The build finished with no errors or warnings so gcc 13 understands at least this part of the C23 standard.
Is there a configuration within STM32CubeIDE to prevent displaying a Syntax error for code the compiler understands?
PS
I checked the generated assembly and it appears that the correct 8-bit code (ldrb) is being generated:
2025-10-14 7:37 AM - edited 2025-10-15 2:04 AM
Hello @StevenG
First let me thank you for posting.
As shown in the screenshot below , STM32CubeIDE 1.19.10 supports the following C language standards:
C23 is not listed: The latest standard available is C18 (ISO C18 or GNU18).
The enum underlying type syntax (enum E : unsigned char { ... }) will not be supported by the current toolchain and will result in a syntax error.
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.
2025-10-15 3:06 AM - edited 2025-10-15 3:09 AM
Note that the syntax highlighting in the editor is separate from the compiler - so even if you do install a compiler which handles C23, the editor syntax checking may not.
This comes up fairly often; eg,
CubeIDE incorrectly flags __attribute__((fallthrough)) as syntax error.
PS:
May well be a general Eclipse thing, rather than CubeIDE specific:
2025-10-15 6:54 AM
Correct. The gcc compiler/linker did the right thing as the assembly showed (which is why I included that image).
The problem lies within either Eclipse's or STM32CubeIDE's syntax highlighter.
My question was if there was a switch somewhere within STM32CubeIDE to tell the syntax highlighter what standard to follow.
2025-10-15 6:56 AM
Note that the current toolchain does support the syntax, it appears it's just STM32CubeIDE's syntax highlighter that does not.
Is there any plan to update the syntax highlighter or a way to adjust how the syntax highlighter works?
2025-10-15 7:07 AM
@StevenG wrote:My question was if there was a switch somewhere within STM32CubeIDE to tell the syntax highlighter what standard to follow.
I haven't found one.
You can turn off the error highlighting completely:
2025-10-16 2:11 AM
Does this help: https://stackoverflow.com/a/50128081 ?
It's not entirely clear (to me) what this actually does - is it telling Eclipse to use the GCC preprocessor/parser instead of its own built-in one?
The Eclipse online help seems no more informative:
2025-10-16 3:18 PM
Not sure if I'm missing something here, but there is a syntax error in your "corrected" version isn't there? You have a comma after 0x43, which is not strictly correct as it's the last item in the enum.
2025-10-17 12:10 AM
A trailing , is ok in an enum list (but not required).
2025-10-17 12:23 AM
Exactly, the parser running in the background of the editor is not the target toolchain.
I came across this issue with most of the Eclipse-based IDE I used. Which is one of serveral reasons I dislike Eclipse.