Using C Libraries for C++ Programs

Yes, C++ can compile C with a C++ compiler and you can link C++ against C. Just be sure that any C function you call uses C linkage. This is made by enclosing the prototype of the C function by an extern "C"

#ifdef __cplusplus
extern "C"{
#endif 

void c_function_prototype();

#ifdef __cplusplus
}
#endif

The headers for the library you are trying to use may already do that.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)