cancel
Showing results for 
Search instead for 
Did you mean: 

syntax error but no compilation error

po221
Senior

hello,

I have a syntax error on one line but no compilation error with stm32cubeide 1.14.1

HANDLE_busQuadSPI_CREATE(g_hbusQSPI_storage , &g_hqspi) ; //syntax error

HANDLE_busSPI_CREATE(g_hbusSPI3_interne , &g_hspi3); // no syntax error

with

#define HANDLE_busQuadSPI_CREATE(var, s) \
		busQuadSPI_handle_t var = { .quadSpiHal = s, .mutex = NULL , .state = QSPI_STATE_Ndef }

and

	#define HANDLE_busSPI_CREATE(var,s) \
			busSPI_handle_t var = { .spiHal = s, .mutex = NULL , .state = SPI_STATE_Ndef }

 

if I don't use macro : no syntax error

busQuadSPI_handle_t g_hbusQSPI_storage = {.quadSpiHal = &g_hqspi , .mutex = NULL , .state = QSPI_STATE_Ndef } ;

HANDLE_busSPI_CREATE(g_hbusSPI3_interne , &g_hspi3);	

 what can happen?

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions

I tried launching the preprocessor with this

https://community.st.com/t5/stm32cubeide-mcus/how-do-i-see-a-c-c-source-file-after-preprocessing-in/td-p/254677

I had a lot of not explicit errors (something not configured I would say) but... Eclipse asked me if I wanted to update the "indexes"

I said yes and I no longer have the syntax error :victory_hand:

I still have to understand what these indexes are...

Thank you all for your help

 

 

View solution in original post

19 REPLIES 19
KnarfB
Principal III

What exactly is the compiler error output and at what line/column in your code.

It could also help you to output the source code after preprocessing (-E option for gcc).

hth

KnarfB

TDK
Guru

The IDE syntax checking is limited. It does its best but isn't going to be 100% accurate. This style of initialization is relatively new and isn't always supported, especially on embedded hardware.

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

Good morning.
There is no compilation error, just a syntax error in the editor.

Macro HANDLE_busQuadSPI_CREATE and HANDLE_busSPI_CREATE are similar but only one syntax problem :thinking_face:, that's what I don't understand.

As the ide doesn't say what the problem is it's not very useful. Do you know if it is possible to deactivate these controls made by ide? What GCC say is probably quite sufficient, right?

 Thanks

Can you screenshot what you're calling an error? Hard to understand when there's no output. Can you hover over the "error" to get more info?

I'm sure error checking can be disabled.

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

If gcc compiles and links without errors (and ideally warnings), your code is okay. Sometimes the STM32CubeIDE shows issues in the Problems tab that I cannot understand either, so I safely ignore them (and switched to VS Code unless I need some advanced debugging features of the STM32CubeIDE).

The reason that you see only one syntax problem might simply be that the parser gives up after the first error detected because it couldn't recover from it.

Further analysis of your issue would require complete code, screenprints,.... But I think, nobody could or would fix it anyway :)

hth

KnarfB

 


@po221 wrote:

As the ide doesn't say what the problem is it's not very useful.


As @KnarfB suggested, try running the source through the preprocessor, and then opening the pre-processed file in the IDE - that should help narrow-down where, exactly, the IDE is complaining.


@TDK wrote:

The IDE syntax checking is limited. 


+1.

I've also seen this in other IDEs: the in-editor syntax checking is not done by the compiler, so it can "disagree".

 


@TDK wrote:

This style of initialization is relatively new 


I wonder if the IDE's checking has a configuration setting which needs changing to accommodate this style?

 

syntaxError1.png

syntaxError2.png

No errors or warnings during compilation
No messages in "Problems"
but an ugly thing on the code which calls out for nothing

I searched for a long time in the preferences to desable error checking but I couldn't find it.