This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C library in C++
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Debamitro Chakraborti <tatai123 at rediffmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Fri, 15 Aug 2003 09:45:42 -0500
- Subject: 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