Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Combining C and C++ code together?

I am quite a beginner to both C and C++ and I have a fundamental question - I come across various code snippets, some in C and some in C++. Sometimes, it would really be nice to be able to combine these two together. I saw OpenCV C code being saved as .cpp and compiled with g++ (example here).

I tried to combine some code - I guess C++ compiler is most likely able to compile C code, but I faced incompatible data structures between OpenCV C and C++ API. Is it possible to write hybrid code then?

Combining C and C++ code together?

I am quite a beginner to both C and C++ and I have a fundamental question - I come across various code snippets, some in C and some in C++. Sometimes, it would really be nice to be able to combine these two together. I saw OpenCV C code being saved as .cpp and compiled with g++ (example here).

I tried to combine some code - I guess C++ compiler is most likely able to compile C code, but I faced incompatible data structures between OpenCV C and C++ API. Is it possible to write hybrid code then?