cancel
Showing results for 
Search instead for 
Did you mean: 

How to fix the problem "invalid storage class for function"

KSae .1
Associate

Hello

I'm new to STM32.

The name of the board I am using is NUCLEO-F091RC.

I am using TureStdio and want to use simple I2C communication.

But I get the error in places like MX_GPIO_Init (void).

The function is an automatically generated function so I don't know how to fix it.

Here is a list of errors:

expected declaration or statement at end of input

invalid storage class for function "MX_GPIO_Init"

invalid storage class for function "MX_I2C1_Init"

invalid storage class for function "MX_TIM14_Init"

invalid storage class for function "MX_USART1_UART_Init"

invalid storage class for function "MX_USART2_UART_Init"

0690X00000DBpHvQAL.png

I have attached my project.

Please help me.

6 REPLIES 6
KnarfB
Principal III

The "expected declaration or statement at end of input" error means that there is an imbalance of curly braces { } somewhere in your code. The "invalid storage class ..." errors are only inherited from that.

In STM32CubeIDE use right-click > Source > Format to auto-indent your code. This might help spotting the error.

Thank you. I will do it immediately.

And what's the relation between missing a curly brace, and an error related to being a static object ?!

The (broken) source code looks like

int main(void)
{
 
void static void MX_GPIO_Init(void) 
{
}

gcc supports nested functions and makes a guess that the author's intention was

int main(void)
{
	static void MX_GPIO_Init(void)
	{
	}
}

which explains somehow both error mesages. gcc is wrong here and I really don't like gnuisms in the source code because they hinder portability.

Big Thanks to you, solved it immediately!

good