views:

43

answers:

1

I have a C++ VS10 project. I want its part to be pure C. So I will have pure C lib and A C++ file that will have part with C code calling that pure Lib.

  • Is it possible? Will I have posebilety to pass data from that C part to C++?
+3  A: 

Yes. See how to mix c and c++.

Of course, you could (probably) just compile the c code with a c++ compiler and save yourself a headache.

If you want to link object files compiled by a c compiler, you'll need to use extern "C" { } to declare the functions, so that they aren't name mangled by the C++ compiler.

It really depends on how you want to build your project. If you're more specific, you'll get better answers.

Stephen
and can I declare includes like #include “cv.h”#include “highgui.h” inside extern "C" { }?
Blender
You can, but note that it may be problematic with nested includes. See this thread: http://developers.sun.com/solaris/articles/external_linkage.html
Stephen