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

19 REPLIES 19

I tried to switch to VSC but it only worked for a day, since CMake throws errors all the time, the extension is not well integrated like stm32cubeIDE can be (I have never had the slightest problem compiling or debugging)

On the other hand, I have tried to change syntax coloring in eclipse but dark mode is dysfonctional and by changing each color in the preferences, some of them disappear each time eclipse is restarted... but it's still much better than with the default theme

CubeIDE is well integrated on a bad editor
VScode is a good editor but poorly integrated, maybe tomorrow will be perfect ??

Could be a general Eclipse thing - not specific to the ST IDE - so try some general Eclipse searches?

eg,

AndrewNeil_0-1706539449334.png

https://www.eclipse.org/forums/index.php/t/75681/

 

 

Have you tried the preprocessor thing?

I spent hours trying to deactivate this error, including the google example, but I was unsuccessful.

Now, I'm trying to understand what you're telling me about the preprocessor...
I have difficulty understanding because the little I think I know is that the preprocessor concerns GCC but here I have no problem with GCC

For vs code I don't use the official STM extension, but stm32-for-vscode by Bureau Moeilijke Dingen (which came first).

KnarfB

 


@po221 wrote:

I'm trying to understand what you're telling me about the preprocessor...


At the moment, you're looking at a macro - so the editor is just saying, "somewhere within this macro I think there's a syntax error"

By running it through the preprocessor, you will see the result of expanding the macro - so the editor will be able to show you more precisely where, exactly, it thinks the error is.

When you can see where, exactly, the editor thinks the error is, that may give more clue as to what the editor thinks the error is ...

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 ✌️

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

Thank you all for your help

 

 


@po221 wrote:

I had a lot of not explicit errors


What errors, exactly?

Just adding the -E option shouldn't affect anything at all configuration-wise.

Note that this does preprocessing only,  so your build will fail - because no object files are generated.

But that doesn't matter - all you need is the preprocessor output.

Rename the .o preprocessor output file to .c, and load that file into the editor.

 


@po221 wrote:

I said yes and I no longer have the syntax error ✌️


I missed that bit!

So the Editor had "cached" some sort of "stale" view of your code, and that was leading to it reporting an "error".

As mentioned above, I've seen this happen with other IDEs - it's one of the drawbacks of having the editor trying to do its own "review" of the code - separate from the compiler itself.

If it's working now, please mark the solution.

 


@po221 wrote:

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


It's how the Editor knows where are your definitions, declarations, references, etc are - eg, so that it can do the 'Go To Definition' without having to do a text search through the entire project.

As you've seen, these can get "out-of-date" - which can lead to some strange issues.

 

lol yes these are just build errors 😅
I just discovered something with the preprocessor and the .o, great!

I could have verified here that the macro was indeed doing the right job earlier

PS : Not obvious the benefit of indexing in Eclipse...

The benefit of indexing is that you can just hit a button and instantly go to definition - without having to wait for it to scan the entire project.

etc.