This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: error: template with C linkage


On 17 September 2011 14:23, Jeffrey Walton wrote:
> /usr//include/cryptopp/cryptlib.h:99: error: template with C linkage
...
> I've tried adding '-x c++' to force c++ in the files.

That's obviously not going to help.

If the compiler complains about a template, it's not compiling C,
because there's no such thing in C.  Ditto for C linkage; everything
in C has C linkage, so there's no concept of any other kind of
language linkage, so no reason a C compiler would ever mention "C
linkage".  So the compiler was already treating the files as
containing C++ (just apparently assuming that everything in a system
directory gets an implicit extern "C" around it.)

Contrary to what some people seem to believe, extern "C" does NOT mean
the compiler is compiling "in C mode" or treating the source code as C
code, it means it's compiling C++ code with C language linkage i.e.
the symbols will be named such that they can be easily called from C
programs because the symbols names will not be mangled.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]