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 09/19/2011 02:19 PM, Ian Lance Taylor wrote:
Marc Glisse<marc.glisse@inria.fr> writes:

On Sun, 18 Sep 2011, Jeffrey Walton wrote:

On Sat, Sep 17, 2011 at 4:21 PM, Jonathan Wakely<jwakely.gcc@gmail.com> wrote:
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.)
OK, thanks. I'm not sure what the implications of "system compiler"
are, but OpenBSD's configuration did not like those files in
/usr/include.

$ g++ -v
Reading specs from /usr/bin/../lib/gcc-lib/i386-unknown-openbsd4.9/4.2.1/specs
Target: i386-unknown-openbsd4.9
Configured with: OpenBSD/i386 system compiler
Thread model: posix
gcc version 4.2.1 20070719
$

Do you have any ideas why a location would make a difference?

Antique platforms have system headers that don't know about C++, so g++ implicitly adds extern "C" around them. And being a system header is a property that depends on the directory the file is in.

This approach is controlled on a target-by-target basis, by the way. If OpenBSD's header files are C++ ready, gcc's OpenBSD target configuration should be changed to define NO_IMPLICIT_EXTERN_C.

Does '-isystem' factor into this in any way? I would hope that using '-isystem' to specify an additional directory of 'system' header files would not also turn on implicit 'extern "C"' mode.


If you are curious, we use '-isystem' to have GCC relax our warning/error modes on header files that are nominally part of our project but are installed into 'system' locations (like /opt/<package>/include).

--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kfleming@digium.com | SIP: kpfleming@digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com & www.asterisk.org


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