|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Crazy compiler error after including <vector> |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|