This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C library in C++


Hi Debamitro,

Usually with a problem like this, it's because the C header files were not created with C++ in mind, and don't have the C linkage specified for C++.

This will cause C++ name mangling on their C identifiers, which won't match up to the identifiers present in their archive library.

To get around that, do this with those (naughty?) C header files in your C++ program:

Old...
#include "Qt/xxx.h"

New...
extern "C" {
#include "Qt/xxx.h"
}

Another solution that's a little bit less cluttered in your own source code is to make your own C++ version of their non-C++-savvy C header files.

--------8<--------
// Qt/xxx.hpp
extern "C" {
#include "Qt/xxx.h"
}
--------8<--------

Then you #include "Qt/xxx.hpp", which is merely your C++-savvy wrapper header file.

HTH,
--Eljay



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]