Add C++ class function in main C source file

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User17048
Level 2
Level 2
First like received
Hi,
I have made class c++ file. I want to use the c++ functions in main.c file but it is showing unknown type name error.
0 Likes
5 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

Try renaming main.c to main.cpp.

Regards,
Jesus
0 Likes
User17048
Level 2
Level 2
First like received
Hi,
Sorry I have given half message. I have 3 source files in c with header file. one base c++ file which functions to be used in these three c source files. but it is showing error.
0 Likes
User17048
Level 2
Level 2
First like received
I made the changes to main.cpp. but error occured
"\"C:\\DAVE-4.4.2\\DAVE-4.4.2\\eclipse\\ARM-GCC-49\\bin\\make\"" --output-sync -j4 all
make: *** No rule to make target '../main.c', needed by 'main.o'. Stop.
0 Likes
User17048
Level 2
Level 2
First like received
Hi,
I resolved it I rebuilt it.
And instead of adding function c++ in c, added c in c++. that got solved.
0 Likes
User10239
Level 1
Level 1
Welcome! 10 replies posted 5 replies posted
Dear reader!
Embedding C++ in C isn't directly possible, vice versa does. But it is really possible if you use a cpp wrapper where you return cpp functions to c.
Useful link: https://isocpp.org/wiki/faq/mixing-c-and-cpp
regards
0 Likes