Including C++ code into C project
Posted: Tue Apr 04, 2017 11:49 am
Hi,
My goal is to make a component that read from some sensors. Due to the requirements of the project, the code must be in C++ cause I need to use some pattern design, but the project(Main and other components, should be write with C).
file1.c-----Calls static function---->file2..cpp-----Create an A class----->A
when I try to compile, it simply doesn't work. The .cpp(file2) is not C++ code. And when I try to include into file2 class A, it says that it doesn't find the file(I Tripled check that its ok). #ifdef __cplusplus macro is not defined.
Inside the .mk files I have defined the:
COMPONENT_ADD_LDFLAGS=-lstdc++ -l$(COMPONENT_NAME)
It can not even include <string>, it says that it doesn't find the file.
What am I missing?
Thanks for the support!
My goal is to make a component that read from some sensors. Due to the requirements of the project, the code must be in C++ cause I need to use some pattern design, but the project(Main and other components, should be write with C).
file1.c-----Calls static function---->file2..cpp-----Create an A class----->A
when I try to compile, it simply doesn't work. The .cpp(file2) is not C++ code. And when I try to include into file2 class A, it says that it doesn't find the file(I Tripled check that its ok). #ifdef __cplusplus macro is not defined.
Inside the .mk files I have defined the:
COMPONENT_ADD_LDFLAGS=-lstdc++ -l$(COMPONENT_NAME)
It can not even include <string>, it says that it doesn't find the file.
What am I missing?
Thanks for the support!