2015-09-02 06:02 AM
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 you2015-09-02 06:51 AM
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.
2015-09-02 06:58 AM
Some C compilers tolerate this sloppy C++ syntax, Keil by default will not.
2015-09-04 01:47 AM
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?2016-03-24 07:44 PM
You can fix this when move it to line 856.