Re: Link problems in g++ but not in gcc!!

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

 



Hi L.Suresh,

CAVEAT!

If you make an "ipq.hpp" header file that only contains this...
extern "C" {
#include "ipq.h"
}

...that's just fine if ipq.h does not, itself, include any header files.

But if it does include any header files, your ipq.hpp should include those header files first. And you should use the same guard that ipq.h uses -- but don't DEFINE it, just trigger off of it.
#ifndef ipq_h_once
#include "alpha.h"
#include <stdio.h>
extern "C" {
#include "ipq.h"
}
#endif


You don't want to compromise those other header files by extern "C"-ing them.

If the made-up "alpha.h" is, itself, in the same boat, then do this...
#ifndef ipq_h_once
#include "alpha.hpp" // "C" wrapper around alpha.h
#include <stdio.h>
extern "C" {
#include "ipq.h"
}
#endif

It can turn into a mighty be can-o'-worms if there are lots and lots of header files. Might be easier to instrument (edit) the C header files with the...
#ifdef __cplusplus
extern "C" {
#endif


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