2017-09-12 01:32 AM
Hi everyone,
I'm trying to convert a 'C' generated project with CubeMX in 'Cpp' but I have some problems with that. Indeed with CubeMX I have generate a project to read ADC values. This one work fine. The same project converted in Cpp compile but the value of the ADC is always the same ( 0 ).
Do you have any idea where this problem could come from ?
Thank you for your help and for your time.
Regards Simon #stm32l0 #cpp #eclipse #adc #cubemx Note: this post was migrated and contained many threaded conversations, some content may be missing.2017-09-12 01:51 AM
I would guess the interrupt routine names don't match.
C++ requires a extern 'C' to not mangle object names.
2017-09-12 03:56 AM
So I have to add the extern 'C' on all the libraries in my project ?
Thank you for your help.2017-09-12 04:00 AM
No, Specifically the IRQ Handlers described in the vector table, they are in an assembler file with weak linkage, you have to get the names right to use yours, the C++ names will be mangled.
And perhaps other things where the linkage fails.
2017-09-12 04:10 AM
Thanks a lot for your help.
So in my case the file 'stm32l0xx_it.c' contains the interrupt routine. I have to add the 'extern C' here ? I'm pretty new in this environment it's not easy ahaha.2017-09-12 04:15 AM
C++ behaves like this on PC's too. When you mix C, C++ and Assembler, you need to be aware of name mangling.
2017-09-12 04:19 AM
So I have to change some things on the project but also on the computer ?
2017-09-12 04:26 AM
In my first post, I refrained from commenting this idea to convert auto-generated C code to C++.
But seems it is not the best idea.
Redo all changes on every regeneration of the projects is not the most efficient way ...
I would either wait until Cube can do C++ projects, or stick with C.
2017-09-12 04:32 AM
Ah ok, scuse me...
I had not understood yourmessage in this way...
So for the moment it is not possible to make the ADC libraries work in a C++ project ?