While trying to compile a C++ package, and using the gnulib socket modules to paper over the differences between various vendor implementations, I tripped over the following error on Solaris 2.6 and 7:
"lib/alignof.h", line 28: Error: Template declarations cannot have extern "C" linkage. 1 Error(s) detected. Triggered by the following code in alignof.h: /* Determine the alignment of a structure slot (field) of a given type, at compile time. Note that the result depends on the ABI. Note: The result cannot be used as a value for an 'enum' constant, due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */ #if defined __cplusplus template <class type> struct alignof_helper { char __slot1; type __slot2; }; ... The problem is that the package C++ headers wrap inclusions of C headers in `extern "C"', which seems like a reasonable thing to do. I'm curious who is wrong here: Is it wrong for gnulib's alignof.h to use C++ conditionally and assume that it is not included from inside an `extern "C"' in an outer file? Is it wrong for the package to mistrust the system C headers so much that they are only included to a C++ file inside an `extern "C"' declaration? Or is it wrong for the C++ compiler to complain about use of templates inside `extern "C"'? I have a workaround already (moving `#include <sys/socket.h>' outside the `extern "C"'), but I'm curious about the real culprit, and maybe the gnulib generated headers want to work properly when used like this? Cheers, -- Gary V. Vaughan (g...@gnu.org)
PGP.sig
Description: This is a digitally signed message part