How can we use any C library inside our C ++ code?

How can we use any C library inside our C ++ code? (Can we? Any links to this?) (I am using VS10 and now talking about libs like x264 and OpenCV)

+5
source share
3 answers

Well, you can use any C library from your C ++ code. This is a cool thing with C ++ :-) You just need to include the library headers in your C ++ code and a link to the libraries you use.

Any good library handles the inclusion of a header from C ++. If this is not the case, you must do it yourself with such things as:

#ifdef __cplusplus
extern "C" {
#endif

#include "c_header.h"

#ifdef __cplusplus
}
#endif

: , ifdef , , C ++. , API, .

, opencv C ++ ( , #ifdef opencv). , x264...

my2cents

+2

, , , #include extern "C", ++ C- ..

extern "C" {
#include <library.h>
}

, ++ lib.

+10

, , , include , .  .

0

All Articles