Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mixed Code C/C++
#1
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
Reply
#2
Settings->Tools->Global compiler settings   goto "Toolchain executables"

   
Reply
#3
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)