error: template with C linkage

Jeffrey Walton noloader@gmail.com
Sat Sep 17 13:23:00 GMT 2011


Hi All,

I'm working on a OpenBSD 4.9 system, and I've receiving multiple
"error: template with C linkage" errors. OpenBSD uses a 4.2.1
compiler.
$ gcc --version
gcc (GCC) 4.2.1 20070719
Copyright (C) 2007 Free Software Foundation, Inc.

A typical output is:
g++ -g3 -ggdb -O0 -pipe -fsigned-char -fmessage-length=0
-Woverloaded-virtual -Wreorder -Wformat=2 -Wformat-security
-Wno-unused -fvisibility=hidden -fstack-protector -I. -I./esapi
-I./deps -I/usr/local/include -fpic -c src/codecs/HTMLEntityCodec.cpp
-o src/codecs/HTMLEntityCodec.o
In file included from /usr//include/cryptopp/misc.h:4,
                 from ./esapi/crypto/Crypto++Common.h:24,
                 from src/codecs/HTMLEntityCodec.cpp:12:
/usr//include/cryptopp/cryptlib.h:99: error: template with C linkage
/usr//include/cryptopp/cryptlib.h:247: error: template with C linkage
/usr//include/cryptopp/cryptlib.h:254: error: template with C linkage
/usr//include/cryptopp/cryptlib.h:261: error: template with C linkage
/usr//include/cryptopp/cryptlib.h:268: error: template with C linkage
/usr//include/cryptopp/cryptlib.h:293: error: template with C linkage
/usr//include/cryptopp/cryptlib.h:698: error: template with C linkage

The first offending line in cryptlib.h is:

// VC60 workaround: using enums as template parameters causes problems
template <typename ENUM_TYPE, int VALUE>
struct EnumToType
{
	static ENUM_TYPE ToEnum() {return (ENUM_TYPE)VALUE;}
};

I've tried adding '-x c++' to force c++ in the files. I have also
audited Crypto++ and my code for a 'dangling extern "C"'. Crypto++
uses extern "C" about 13 times (a typical usage is below), and I don't
use it.

#ifdef CRYPTOPP_X64_MASM_AVAILABLE
extern "C" {
void Rijndael_Enc_AdvancedProcessBlocks(void *locals, const word32 *k);
}
#endif

I built Crypto++ from sources (it compiled and self-tested OK) and
then installed it via makefile. So I'm surprised to find Crypto++ is
[supposedly] causing problems.

I found a few bug reports relating to a spurious error, but they
appeared to be for platforms other than x86/x64.

Any ideas?

Jeff



More information about the Gcc-help mailing list