GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-May-2006, 07:35
MichaelS-R MichaelS-R is offline
Junior Member
 
Join Date: Apr 2006
Location: Berkshire, UK
Posts: 65
MichaelS-R is on a distinguished road

error template with C linkage


I am trying to build a project at the moment. However, I currently get a mass of "error template with C linkage" errors. They all relate to GNU ISO C++ library.

The project built perfectly then this suddenly started. Does anyone have any suggestions?

Thanks,
Michael.

Running under FC4.
  #2  
Old 16-May-2006, 14:34
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough

Re: error template with C linkage


Are you compiling your project as a C++ project?
  #3  
Old 17-May-2006, 01:56
MichaelS-R MichaelS-R is offline
Junior Member
 
Join Date: Apr 2006
Location: Berkshire, UK
Posts: 65
MichaelS-R is on a distinguished road

Re: error template with C linkage


Hi

Yes, I am sure that it is compiling in C++. The full list of messages is attached. Most of the problems seem to be with the standard libraries. This all compiled and linked perfectly a few days ago with the same include files (apart from <vector>, I think), although <map> was included.

Foolishly I do not have an earlier version to revert to!

Anyway, the fulll build output is as follows:

Code:
Building the whole Project: mrmCalcEngine ... make make all-recursive make[1]: Entering directory `/home/miker/Projects/mrmCalcEngine' Making all in include make[2]: Entering directory `/home/miker/Projects/mrmCalcEngine/include' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/home/miker/Projects/mrmCalcEngine/include' Making all in src make[2]: Entering directory `/home/miker/Projects/mrmCalcEngine/src' if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include/mysql++ -I/home/miker/Projects/mrmCalcEngine/include -I/usr/local/mysql/include/mysql -Wall -g -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.cc; \ then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi/usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:131: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:142: error: declaration of C function ‘const std::_Rb_tree_node_base* std::_Rb_tree_increment(const std::_Rb_tree_node_base*)’ conflicts with /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:139: error: previous declaration ‘std::_Rb_tree_node_base* std::_Rb_tree_increment(std::_Rb_tree_node_base*)’ here /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:148: error: declaration of C function ‘const std::_Rb_tree_node_base* std::_Rb_tree_decrement(const std::_Rb_tree_node_base*)’ conflicts with /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:145: error: previous declaration ‘std::_Rb_tree_node_base* std::_Rb_tree_decrement(std::_Rb_tree_node_base*)’ here /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:150: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:219: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:293: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:299: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:324: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:707: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:717: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:727: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:734: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:741: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:748: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:755: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:762: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:784: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:802: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:819: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:864: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:891: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:948: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1002: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1013: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1024: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1038: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1050: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1086: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1102: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1115: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1125: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1146: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1168: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1179: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1197: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1215: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1233: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1251: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1261: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_tree.h:1276: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_map.h:89: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_map.h:636: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_map.h:653: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_map.h:660: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_map.h:667: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_map.h:674: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_map.h:681: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_map.h:688: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:70: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:75: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:80: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:106: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:618: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:635: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:642: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:649: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:656: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:663: error: template with C linkage /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/bits/stl_multimap.h:670: error: template with C linkage make[2]: *** [main.o] Error 1 make[2]: Leaving directory `/home/miker/Projects/mrmCalcEngine/src' make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 make[1]: Leaving directory `/home/miker/Projects/mrmCalcEngine' Completed ... unsuccessful Total time taken: 1 secs

Thanks,

Michael.
  #4  
Old 17-May-2006, 08:38
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,309
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: error template with C linkage


Quote:
Originally Posted by MichaelS-R
The project built perfectly then this suddenly started.
.
.
.
Yes, I am sure that it is compiling in C++.


The error messages are a symptom of what I call a 'dangling extern "C"'

If some header that is #included before <map> or <vector> has an "extern "C" statement that is not associated with a function, you might see these messages.

The things that come to mind are:
1. You have a local header file that is improperly formed. (Have you made any changes to your project header files? Are any of them #included before <map> or <vector> or any other standard library headers?)

2. One of the standard library header files (or other header files that are included before <map> or <vector>) has become corrupted. This is unlikely unless you have been poking around in some compiler/library directories while logged in as root. And I just know that you haven't done that. Have you done any compiler updates since you started? (yum update or rpm -U or whatever) If so, then maybe you can revert to a previous version and test again.

An example of the dangling extern "C"

CPP / C++ / C Code:
#include <iostream>
#include "oops.h"
#include <map>

using namespace std;

int main()
{
    cout << "Hello gidforums" << endl;
    return 0;
}

CPP / C++ / C Code:
// oops.h
#ifdef __cplusplus
extern "C"
#endif
//    void foo(void); // this was erroneously commented out, leaving the extern "C" dangling

Output:
Code:
/usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_tree.h:131: error: template with C linkage /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_tree.h:142: error: declaration of C function ‘const std::_Rb_tree_node_base* std::_Rb_tree_increment(const std::_Rb_tree_node_base*)’ conflicts with /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_tree.h:139: error: previous declaration ‘std::_Rb_tree_node_base* std::_Rb_tree_increment(std::_Rb_tree_node_base*)’ here /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_tree.h:148: error: declaration of C function ‘const std::_Rb_tree_node_base* std::_Rb_tree_decrement(const std::_Rb_tree_node_base*)’ conflicts with /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_tree.h:145: error: previous declaration ‘std::_Rb_tree_node_base* std::_Rb_tree_decrement(std::_Rb_tree_node_base*)’ here /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_tree.h:150: error: template with C linkage . . (40 other error messages deleted) . /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_tree.h:1458: error: template with C linkage


Note that stl_tree.h is the same for your 64-bit gcc as it is for my 32-bit gcc. Note that if I put the #include "oops.h" after #include <map> the errors don't occur. (Maybe a hint for you to track down the dirty dog that is causing the problem.)


Regards,

Dave
Last edited by davekw7x : 17-May-2006 at 09:25.
  #5  
Old 17-May-2006, 10:12
MichaelS-R MichaelS-R is offline
Junior Member
 
Join Date: Apr 2006
Location: Berkshire, UK
Posts: 65
MichaelS-R is on a distinguished road

Re: error template with C linkage


davekw7x - thank you very much for that. It was where I was heading - checking header files etc.

The offending file appears to be param.h, although I cannot see what is wrong wtih it... is putting the #include inside the extern "C" section the problem?

CPP / C++ / C Code:
#ifndef _PARAM_H
#define _PARAM_H

#ifdef __cplusplus
extern "C"
{
#endif

#include <map>
#include <string>
	
using std::string;
using std::map;
	
#define PARAM_SEPARATORS "\t ,"

class params
{	private:
	map<string, string> pmap;
			
	public:
	params(){};
	~params(){};
		
	int init(char *fname);
	
	int get_param(int *val_p, const string key);
	int get_param(string *val_p, const string key);
	int get_param(long *val_p, const string key);
	int get_param(float *val_p, const string key);
	int get_param(unsigned *val_p, const string key);
	int get_param(ulong *val_p, const string key);
};

extern params param_scenario;

#ifdef __cplusplus
}
#endif

#endif /* _PARAM_H */
The workaround I found was to eliminate param.h from main.cc (a not too cludgy workaround) and everything is fine. Still cannot quite understand why...

Thanks,

Michael.
  #6  
Old 17-May-2006, 10:20
MichaelS-R MichaelS-R is offline
Junior Member
 
Join Date: Apr 2006
Location: Berkshire, UK
Posts: 65
MichaelS-R is on a distinguished road
Thumbs up

Re: error template with C linkage


Answered my own question - all working fine now - thanks.
  #7  
Old 17-May-2006, 11:09
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,309
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: error template with C linkage


Quote:
Originally Posted by MichaelS-R
Answered my own question - all working fine now - thanks.

For others who might be interested: look in any standard header file where code may be used in C as well as C++ programs, for example <ctype.h>

CPP / C++ / C Code:
#ifdef __cplusplus
extern "C" {
#endif
.
.
.
Here are all of the function prototypes and, maybe other stuff

#ifdef __cplusplus
}  /* this brace matches the one on the extern "C" line */
#endif

Now if you have anything else that has (or includes) C++ function prototypes in the first #ifdef block, the extern "C" is dangling. (Pretend you are the C preprocessor and see what it gives you and compare with my simple "oops" example.)

Regards,

Dave
 
 

Recent GIDBlogProblems with the Navy (Enlisted) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:02.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.