View Antoni Milton's profile on LinkedIn

Saturday, March 3, 2012

Merging “C” module into C++ project

Step -1

   Compile the C module alone with C++ compiler. For that we can put the following line in top and bottom of the file

// In the top of the file
#ifdef __cplusplus
extern "C" {
#endif
// in the bottom
#ifdef __cplusplus
}
#endif

OR

If you have only one header file going to include in C++ module than,
extern "C" {
// Get declaration for fun(int i, char c, float x)
#include "C_MOD_code.h"
}

Step-2
If the C module going to access the functions from C++ module, then declare like below
extern "C" void fun(int i, char c, float x);

step-3
Once the compilation get successes than link with C++ linker

No comments: