2020-08-06 10:34 PM
I am getting errors "undefined reference to two c function " screenshot and whole project archived file is attached here.
This project was initially generated by STM32CubeIde as c project then I converted it to c++ using the option "convert to c++ project", main.c was renamed to main.cpp. I don't have any issue with it.
I added the source .c and include .h files appropriately, I still get the error as shown above the two functions.
2020-08-06 10:38 PM
2020-08-06 10:40 PM
2020-08-06 10:41 PM
2020-08-07 01:48 AM
Hi,
In your "Radio_RF_Control.h", try this instead:
#ifdef __cplusplus
extern "C" {
void NRF24L01_One_Time_Configuartion(void);
void NRF24L01_Schedule_And_Event_Control(void);
}
#endif
Your C code needs to be seen like C code at link time by the C++ linker, that is why these directives need to be added.
For further reading maybe check this: https://stackoverflow.com/questions/3789340/combining-c-and-c-how-does-ifdef-cplusplus-work
Side note, when downloading your project I notice that the project structure is slightly broken. Not your fault, this is an Eclipse/CDT bug.
It can be fixed. Look at the project explorer: You have two folders "Suporting_Devices/Radio_Module/NRF24L01" and "Suporting_Devices".
Both of them have exclamation mark on the folder icon...
This issue occurs when you:
Issue happens when you perform step3. folder2 already considered a source code folder since this property is inherited from its parent.
If you want to fix this. Make back-up copy of Support_Devices on file system. Remove both folders in project explorer. Add Supporting_Devices again into project and only perform step2 above!
2020-08-10 10:32 PM
Thanks you very much Mattias the solution worked well.
I modified my project as per your second suggestion.