Re: C library in C++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux