I have got a header file that includes boost libraries and I need to include this header file in a source code written in C. Is it possible to do this?
Thanks!
I have got a header file that includes boost libraries and I need to include this header file in a source code written in C. Is it possible to do this?
Thanks!
No, you can't generally include C++ headers in a C program. You'll need to separate out the declarations that C programs might use into a separate header, and make sure these have the correct language linkage in C++:
#ifdef __cplusplus
extern "C" {
#endif
// C-compatible declarations here
#ifdef __cplusplus
}
#endif
Use adapter pattern (http://en.wikipedia.org/wiki/Adapter_pattern) this post already discusses simmilar issue: Using C++ library in C code)