C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 5th, 2003, 05:19 PM
kavi_s kavi_s is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 24 kavi_s User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Crazy compiler error after including <vector>

Hi All,

I am getting all this garbage from the C++ compiler after adding the line #include <vector> into my program. I didn't use any vectors as yet. I also included the line "using namespace std"

I don't know where my error could be. I am using a makefile right now, so I don't know if the error could be in the way I am compliling my file.

This is the message I get when I compile:

Code:
g++ -Wall -c -g ../source/lem.cpp
In file included from /usr/um/gnu/gcc-2.95.3/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/../../../../include/g++-3/stl_algobase.h:56,
                 from /usr/um/gnu/gcc-2.95.3/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/../../../../include/g++-3/vector:30,
                 from ../source/../include/lem.h:17,
                 from ../source/lem.cpp:12:
/usr/um/gnu/gcc-2.95.3/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/../../../../include/g++-3/stl_iterator.h:169: `template <class _Iter> typename iterator_traits<_Iterator>::value_type * value_type(const _Iter &)' redeclared as different kind of symbol
../source/../include/../include/../include/rough.h:25: previous declaration of `typedef unsigned int value_type'
../source/../include/../include/../include/rough.h:25: previous non-function declaration `typedef unsigned int value_type'
/usr/um/gnu/gcc-2.95.3/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/../../../../include/g++-3/stl_iterator.h:169: conflicts with function declaration `template <class _Iter> typename iterator_traits<_Iterator>::value_type * value_type(const _Iter &)'



Line 17 of lem.h is the include line I was talking about (#include <vector>) while Line 12 of lem.cpp is where the #include lem.h line is.

Can anyone tell me what I might be doing wrong?


Thanks,
Kavi

Reply With Quote
  #2  
Old June 7th, 2003, 01:40 AM
grumpy's Avatar
grumpy grumpy is offline
Left due to despotic ad-min
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2003
Posts: 1,042 grumpy User rank is Corporal (100 - 500 Reputation Level)grumpy User rank is Corporal (100 - 500 Reputation Level)grumpy User rank is Corporal (100 - 500 Reputation Level)grumpy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 53 m 47 sec
Reputation Power: 8
It's a bit hard to be specific without looking at your source code.

But, at a guess, the code in either lem.h or lem.cpp either #define's or does a typedef of something called value_type. This
is different to what is being done in the standard vector, and the compiler can't work out which to use.

The solution is probably to #include <vector> at the top
of lem.h. (As a rough rule, system headers should always
be #include'd before user headers anyway).

If that doesn't work, I suggest you try to find a small code sample that recreates your problem. Once you've done that, you'll either have worked out what's happening or have a code sample that people can help you with.

Reply With Quote
  #3  
Old June 7th, 2003, 10:36 AM
kavi_s kavi_s is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 24 kavi_s User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hey grumpy,

Yes, it was the value_type definition, but I figured it out before I read ur post, so I didn't think of including vector before the other header file....so I ended up changing the name from value_type to val_type......!! That was kind of annoying. I will try including vector at the beginning instead and see what happens! By the way, the value_type definition in the other header file was just a typedef for unsigned int. Do u know what STL's value_type is? Thanksfor your help

Kavi

Reply With Quote
  #4  
Old June 14th, 2003, 06:24 AM
grumpy's Avatar
grumpy grumpy is offline
Left due to despotic ad-min
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2003
Posts: 1,042 grumpy User rank is Corporal (100 - 500 Reputation Level)grumpy User rank is Corporal (100 - 500 Reputation Level)grumpy User rank is Corporal (100 - 500 Reputation Level)grumpy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 53 m 47 sec
Reputation Power: 8
value_type is a common typedef within STL types that expands to the type used to instantiate a template.

Or, less formally, std::vector<Dog>::value_type is a typedef of Dog. std::list<Dog>::value_type is also a typedef of Dog.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Crazy compiler error after including <vector>


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT