2015-09-27 07:07 AM
Hi,
when I generate code for the STM32L0 in CubeMX, my compiler discovers the following problem:~/projecten/SunnaBat/software/Controller/toepassing/cube/SunnaBat/Src/adc.c:149:47: error: declaration of 'hadc' shadows a global declaration [-Werror=shadow]void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
^
~/projecten/SunnaBat/software/Controller/toepassing/cube/SunnaBat/Src/adc.c:45:19: note: shadowed declaration is here
ADC_HandleTypeDef hadc; Same deal with other peripherals like IDWG or I2C. The generated software has a local variable named exactly the same as a global variable! This is a recipe for confusion or worse. My compiler is arm-none-eabi-g++ (I won't use gcc, since most of my code is c++) Has anybody found a way to make the tool generate proper function variable names? I can change them by hand but every time I re-generate from the tool I lose my changes and I need to do it all again. Perhaps ST could test the code with a c++ compiler, they are much more strict on typechecking and names than a c compiler. Thanks, Ewout Boks
2015-09-28 08:17 AM
Hi boks.ewout.001,
The issue is reported to dedicated team. As a workaround (maybe you already know it), generate the code without ticking the option ''Generate peripheral initialization as a pair of '.c/.h' files per IP'' in project settings. -Shahrzad-2015-10-02 02:36 AM
2015-10-02 03:42 AM
>Perhaps ST could test the code with a c++ compiler, they are much more strict on typechecking and names than a c compiler.
I think this is an incorrect assumption. With proper compiler options (like
-Wall
), every average C compiler will warn about this issue. Judged by the number of issue reports, the CubeMX development team is either lax on testing, or significantly overloaded. I tend to assume the latter. However, I don't want to act as Beta tester, so I will not consider using the Cube software before it matured significantly. My estimation is about 2 years.2015-10-11 11:15 AM
Dear user,
Which version of STM32CubeMX are you using? Using latest MX 4.10.1 no such error is encountered as ADC code generation generates for ADC instance 1 the following: ADC_HandleTypeDef hadc1; Best regards