#ifndef MAINCPP_H
#define MAINCPP_H
extern "C"
{ void displaylistfun(void);
void strfun(void);
}
#endif
Don't know why i am getting this error, I am trying to call Cpp function in .c file
#ifndef MAINCPP_H
#define MAINCPP_H
extern "C"
{ void displaylistfun(void);
void strfun(void);
}
#endif
Don't know why i am getting this error, I am trying to call Cpp function in .c file
extern "C" { ... } is a C++-specific thing, when you include the header file in a C source file you should be getting errors.
You need to use conditional compilation to have a header file that can be included in both C and C++ source files:
#ifndef MAINCPP_H
#define MAINCPP_H
#ifdef __cplusplus
// Only in C++
extern "C" {
#endif
void displaylistfun(void);
void strfun(void);
#ifdef __cplusplus
}
#endif
#endif // MAINCPP_H
Remember to include this header file on both the C++ and the C source files (so the C++ compiler knows that the functions are extern "C").