EmBitz

Full Version: Mixed Code C/C++
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I will use in my project the skeleton, which is created from ST Micros Cube MX, it is native C-code With a switch with 

Code:
#ifdef __cplusplus
extern "C" {
#endif
// all of your legacy C code here
#ifdef __cplusplus
}
#endif

I go on to programm in C++.  The compile process seems to be good. But the linker mentioned during linking the object files problems like "unknown  synthax". My thought are going in the direction, the compiler for C is the gcc, for C++ it is g++. Because of this, the linkersymbols are probably not matching.
My question is, how can I use the g++-compiler within embitz always for the C-Code (without rename main.c to main.cpp)? Is this possible? Or is it a completely different reason behind? Maybe, I have not considered all points from here ( How to mix C and C++, C++ FAQ (isocpp.org)) But for now, I see no other solution.

Thanks,
Jan
Settings->Tools->Global compiler settings   goto "Toolchain executables"

[attachment=168]
But be aware that type casting in g++ is different than with GCC.

e.g.
Code:
        switch( (settingsIndex_Tp)pppL)


becomes

Code:
        switch( reinterpret_cast<settingsIndex_Tp &>(pppL))


But the normal, preferable, way is what you already are doing.  C files are C files and not Cpp files.