[Bug 826] libiptc/libip6tc.h doesn't specify C linkage
bugzilla-daemon at netfilter.org
bugzilla-daemon at netfilter.org
Thu Jun 20 10:57:57 CEST 2013
https://bugzilla.netfilter.org/show_bug.cgi?id=826
--- Comment #2 from Quentin Armitage <quentin at armitage.org.uk> 2013-06-20 10:57:57 CEST ---
If I want to include libiptc/libip6tc.h in a C++ program, I have to wrap the
#include in a extern "C" section, i.e.
extern "C" {
#include <libiptc/libip6tc.h>
}
On the other hand, this is not necessary for libiptc/libiptc.h since it already
includes the extern "C" section in the header file.
Since libiptc/libip6tc.h already includes a check for #ifdef __cplusplus, it is
clearly attempting to be compatible with C++, but without the extern "C"
statement, it isn't fully. This mean that in my C++ code, which uses both IPv4
and IPv6, the way I have to include the headers is inconsistent:
#include <libiptc/libiptc.h>
extern "C" {
#include <libiptc/libip6tc.h>
}
I have tested nested extern "C" sections, e.g.
extern "C" {
// Some code
extern "C" {
// some more code
}
}
and that compiles without a problem, so adding extern "C" to libip6tc.h
shouldn't break any code that already includes includes it within an extern "C"
section.
Finally, libiptc/libiptc.h and libiptc/libip6tc.h are so similar that it seems
inconsistent that one should have the external linkage statement and not the
other.
This isn't really a problem for me now, since I have added the necessary
externs to my code, but I thought that it would be helpful to point out the
inconsistency and may help others in the future.
I will attach a patch.
--
Configure bugmail: https://bugzilla.netfilter.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
More information about the netfilter-buglog
mailing list