cancel
Showing results for 
Search instead for 
Did you mean: 

Need help understanding error

christiaan2
Associate II
Posted on September 02, 2015 at 15:02

Hi

I am using the STM32F303RE and SdPeriph library v1.2.3. Whenever I build my code I get this error:

STM32F30x_StdPeriph_Driver\src\stm32f30x_rcc.c(994): error:  #268: declaration may not appear after executable statement in block

uint32_t apb1presc = 0;

The rcc.c section is as follows:

#ifdef STM32F303xE  

  uint32_t apb1presc = 0;   ----This is line 994----

  apb1presc = APBAHBPrescTable[tmp];

  /* TIM2CLK clock frequency */

  if(((RCC->CFGR3 & RCC_CFGR3_TIM2SW) == RCC_CFGR3_TIM2SW)&& (RCC_Clocks->SYSCLK_Frequency == pllclk) \  && (apb1presc == ahbpresc))

Is this a bug in the library? I have made no modifications to the library files.

Thank you
4 REPLIES 4
Amel NASRI
ST Employee
Posted on September 02, 2015 at 15:51

Hi brand.christiaan,

This error means that the compiler doesn't accept to declare variable after executing some code, not at the beginning of the function.

Here, it is not allowed to declare ''apb1presc '' at this level.

I will report internally this issue.

-Mayla-

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.

Posted on September 02, 2015 at 15:58

Some C compilers tolerate this sloppy C++ syntax, Keil by default will not.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
christiaan2
Associate II
Posted on September 04, 2015 at 10:47

Any advice for a fix that I could implement in the meantime?

Edit:

I managed to fix the compiler issue by moving the apb1presc variable declaration to the private variables in line 133 of rcc.c. I do not know if this could cause any other issues?
thaian1112006
Associate II
Posted on March 25, 2016 at 03:44

You can fix this when move it to line 856.