2024-04-18 09:03 AM
Hello ST community when i build my code in STM32F407VG or in STM32H735IG many warrnings& error as shown :
../Core/Src/main.c: In function 'CDC_HANDLE':
../Core/Src/main.c:112:5: warning: 'main' is normally a non-static function [-Wmain]
112 | int main(void)
| ^~~~
../Core/Src/main.c:208:13: error: invalid storage class for function 'MX_GPIO_Init'
208 | static void MX_GPIO_Init(void)
| ^~~~~~~~~~~~
../Core/Src/main.c:249:1: error: expected declaration or statement at end of input
249 | }
| ^
../Core/Src/main.c: At top level:
../Core/Src/main.c:52:13: warning: 'MX_GPIO_Init' used but never defined
52 | static void MX_GPIO_Init(void);
| ^~~~~~~~~~~~
../Core/Src/main.c:241:6: warning: 'Error_Handler' defined but not used [-Wunused-function]
241 | void Error_Handler(void)
| ^~~~~~~~~~~~~
../Core/Src/main.c:208:13: warning: 'MX_GPIO_Init' defined but not used [-Wunused-function]
208 | static void MX_GPIO_Init(void)
| ^~~~~~~~~~~~
../Core/Src/main.c:162:6: warning: 'SystemClock_Config' defined but not used [-Wunused-function]
162 | void SystemClock_Config(void)
| ^~~~~~~~~~~~~~~~~~
../Core/Src/main.c:112:5: warning: 'main' defined but not used [-Wunused-function]
112 | int main(void)
| ^~~~
make: *** [Core/Src/subdir.mk:34: Core/Src/main.o] Error 1
"make -j2 all" terminated with exit code 2. Build might be incomplete.
17:10:20 Build Failed. 3 errors, 6 warnings. (took 1s.612ms)
so can you help me & say what can i do . thanks
2024-04-22 09:13 AM
Hello @MOns1 and welcome to the community,
Could you please specify what you have configured for the MCU. This would be more helpful in reproducing the problem.
Thanks,
Rim.
2024-04-22 09:34 AM - edited 2024-04-22 09:35 AM
@MOns1 wrote:../Core/Src/main.c:112:5: warning: 'main' is normally a non-static function [-Wmain]
This is very true!
If you make main() static, that means it won't be visible to the startup code to call it!
It sounds like something has gone very wrong with your code - maybe you've lost a closing brace somewhere?
Or added a spurious extra opening brace?
Especially with errors like this:
@MOns1 wrote:../Core/Src/main.c:249:1: error: expected declaration or statement at end of input
249 | }
| ^
It's saying that it's got to the end of the file, but it thinks it's still in the middle of a function somewhere - ie, there should be more code to follow!
This is, indeed, typical of what happens when you lose a closing brace somewhere ...