2021-04-29 11:33 PM
2021-04-30 01:17 AM
Your problem description seems to miss some details.
The more detailed your description, the better the answers will match.
C and C++ calls are not directly compatible, cf. name-mangling.
You would need to declare every C++ function callable from C as "extern "C" ".
2021-04-30 01:33 AM
Well,
I started from a project of a STM Workshop.
Then I added a second project that is of type static library and for the same Discovery Board.
I started typing some C++ classes in the library and everything compiles. Then I added
a reference to the Library project and from the main project I can see the types of the library.
Then i added an Initialize.h file in which i declared a function in Initialize.cpp with decoration extern "C"
but inside this function I cannot type any C++ code.
Attached is the project , If you could please take a look.
Regards
2021-04-30 01:35 AM
I cannot understand, I used the same procedure used fro touchgfx and they are cpp code. I think somehow it does not recognize cpp in the library
when imported but the library is created in C++. I checked the option when i created.
2021-04-30 02:17 AM
Sorry, but I don't use Cube/HAL or STM Workshop. Nor touchgfx.
> Then i added an Initialize.h file in which i declared a function in Initialize.cpp with decoration extern "C"
Does this mean, you want to use a C++ library from a C code application ?
Then why not sticking to C++ ?
And if both are C++, you do not need to restrict the library to the C linker capabilitites.
2021-04-30 02:21 AM
Possible.
Not all the code of the project is C++, some code especially drivers are in C++.
This is not a problem
2021-04-30 04:03 AM
In CubeIDE, right click on the project and select "convert to C++"