We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I need to use a library that relies on FLASH_Unlock and functions following it, however upon calling that function I get an error saying the function is invalid in C99. The library I use has an example file which is written in mdk v4 and works just fine. Is there a way I can use FLASH_Unlock() function?
Broman3100 said:I need to use a library that relies on FLASH_Unlock
What library, exactly?
Broman3100 said: I get an error saying the function is invalid in C99
Copy & paste the full, unabridged build output, and show the section of source code where the error is reported.
(for the build output, just use steps 1 & 2).
I use eeprom emulation library for stm32f0xx. ( https://www.st.com/content/st_com/en/products/embedded-software/mcu-mpu-embedded-software/stm32-embedded-software/stm32-standard-peripheral-library-expansion/stsw-stm32117.html )
../Src/main.c(69): warning: #223-D: function "FLASH_Unlock" declared implicitly
This is the main error I get, I also get multiple other errors which is because FLASH_Unlock doesnt work f.ex:
..\Src\eeprom.c(160): warning: #223-D: function "FLASH_ErasePage" declared implicitly FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS); ..\Src\eeprom.c(162): error: #20: identifier "FLASH_COMPLETE" is undefined if (FlashStatus != FLASH_COMPLETE) ..\Src\eeprom.c(167): warning: #223-D: function "FLASH_ProgramHalfWord" declared implicitly FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE); ..\Src\eeprom.c(179): error: #20: identifier "FLASH_COMPLETE" is undefined if (FlashStatus != FLASH_COMPLETE) ..\Src\eeprom.c(192): error: #20: identifier "FLASH_COMPLETE" is undefined if (FlashStatus != FLASH_COMPLETE) ..\Src\eeprom.c(200): warning: #223-D: function "FLASH_ErasePage" declared implicitly FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);
This is ST's code - nothing to do with ARM.
The message does not say anything about the function being invalid in C99!
"implicitly declared" means that you have failed to provide an explicit declaration - ie, either a prototype or definition of that function.
With all those "undefined" errors, you have probably omitted to include a required header file.
Or, perhaps, not correctly configured the project - so that the appropriate target-specific options are not defined.
You need to go back to the ST documentation on how to properly set up a project using this library.
ST should provide an example to get you started ...
Likely because you are not including one or more .H file.
The settings for the Include Path pull from the wrong, or inappropriate place. ie not consistent with the .C file providing the functionality. The .C and .H need to be contemporaneous.
The settings for the C/C++ command line don't define USE_STDPERIPH_DRIVER, etc
sorry for late reply, as you can see the error message I get on the code itself is different
Also st did provide clear example, but I cannot use it as a template as it is in mdk v4 and I'm using v5
The problem is still the fact that you haven't provided the declaration.
C99 will not let you get away with that.
That's what you need fix - as already described.
could you please tell me how to do that? Sorry for asking a lot my programming skills are basically very low.
Then you really need to work on your programming skills first.
See: https://www.avrfreaks.net/comment/2843566#comment-2843566
http://c-faq.com/decl/decldef.html
Thanks for you help!
I'm afraid teaching programming basics is outside the scope of this forum.