Subject: Re: compiler issues C/C++ linkage
To: Martin Husemann <martin@duskware.de>
From: Tom <th.tom@gmx.de>
List: netbsd-users
Date: 12/20/2005 20:25:09
Martin,

Am Dienstag, 20. Dezember 2005 15:40 schrieb Martin Husemann:
> If you could show us a small sample program that causes this problem, we
> could check wether it's a problem in the application or a bug in the
> installed headers.

I have a glimps what's happening. However I didn't got a clue why (ok, maybe I 
am on the wrong track on library creation)

following scenario:

testcompile.cpp:
#include "testinc.h"

#include <string>
#include <iostream>

int main()
{
  std::string hallo("String Test");

  std::cout<<hallo<<std::endl;
}

testinc.h:
#ifndef testinc_h
#define testinc_h

#include <list>

#endif

if both files are in the same directory, everything is ok. When I copy the 
testinc.h file to /usr/include and change the #include "testinc.h" to 
#include <testinc.h> in testcompile.cpp, I will get the following errors:

In file included from /usr/include/g++/iosfwd:46,
                 from /usr/include/g++/bits/stl_algobase.h:70,
                 from /usr/include/g++/list:67,
                 from /usr/include/testinc.hpp:4,
                 from compilerTest.cpp:1:
/usr/include/g++/bits/c++locale.h:59: error: template with C linkage
In file included from /usr/include/g++/iosfwd:48,
                 from /usr/include/g++/bits/stl_algobase.h:70,
                 from /usr/include/g++/list:67,
                 from /usr/include/testinc.hpp:4,
                 from compilerTest.cpp:1:
/usr/include/g++/bits/stringfwd.h:49: error: template with C linkage
/usr/include/g++/bits/stringfwd.h:52: error: template with C linkage
/usr/include/g++/bits/stringfwd.h:56: error: template with C linkage
In file included from /usr/include/g++/iosfwd:49,
                 from /usr/include/g++/bits/stl_algobase.h:70,
                 from /usr/include/g++/list:67,
                 from /usr/include/testinc.hpp:4,
                 from compilerTest.cpp:1:
/usr/include/g++/bits/fpos.h:57: error: template with C linkage
In file included from /usr/include/g++/bits/stl_algobase.h:70,
[........]

What is wrong with this? Couldn't I create library header files like that?

Tom 

PS: I use "gcc (GCC) 3.3.3 (NetBSD nb3 20040520)"