Home > Archive > VC STL > March 2006 > Including <vector> in VC6 project - compile errors
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Including <vector> in VC6 project - compile errors
|
|
| cmiddlebrook@btinternet.com 2006-03-08, 7:58 am |
| Hi there,
I have a VC6 project to which I would like to use the std::vector
class. When I include it i get a bunch of compile errors which are
highlighted in the <new> header. These are as follows:
--------------------Configuration: vc_rars - Win32
Debug--------------------
Compiling...
drivers.cpp
c:\program files\microsoft visual studio\vc98\include\new(35) : error
C2059: syntax error : 'string'
c:\program files\microsoft visual studio\vc98\include\new(35) : error
C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(35) : error
C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\new(36) : error
C2059: syntax error : 'string'
c:\program files\microsoft visual studio\vc98\include\new(37) : error
C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(37) : error
C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const
struct std::nothrow_t &)' : overloaded function differs only by return
type from 'void *(__cdecl *__cdecl op
erator new(void))(unsigned int)'
c:\program files\microsoft visual studio\vc98\include\new(35) :
see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\new(41) : error
C2059: syntax error : 'string'
c:\program files\microsoft visual studio\vc98\include\new(42) : error
C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(42) : error
C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,void
*)' : overloaded function differs only by return type from 'void
*(__cdecl *__cdecl operator new(void))(unsig
ned int)'
c:\program files\microsoft visual studio\vc98\include\new(35) :
see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\new(42) : error
C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\new(42) : error
C2065: '_P' : undeclared identifier
c:\program files\microsoft visual studio\vc98\include\memory(16) :
error C2059: syntax error : 'string'
c:\program files\microsoft visual studio\vc98\include\memory(17) :
error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\memory(17) :
error C2784: 'void *(__cdecl *__cdecl operator new(void))(unsigned
int,class std::allocator<`template-parameter257'> &)' : could not
deduce template argument for 'void *(__cdecl *)(u
nsigned int,class std::allocator<_Ty> &)' from 'void *(__cdecl
*)(unsigned int)'
c:\program files\microsoft visual studio\vc98\include\memory(17) :
error C2785: 'void *(__cdecl *__cdecl operator new(void))(unsigned
int,class std::allocator<`template-parameter257'> &)' and 'void
*(__cdecl *__cdecl operator new(void))(unsigned int
)' have different return types
c:\program files\microsoft visual
studio\vc98\include\memory(16) : see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\memory(17) :
error C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\memory(20) :
error C2954: template definitions cannot nest
d:\source\rars\rars\list.h(106) : warning C4284: return type for
'List<class GA_Driver *>::iterator::operator ->' is 'class GA_Driver **
' (ie; not a UDT or reference to a UDT. Will produce errors if applied
using infix notation)
d:\source\rars\rars\ga_driver_pop.h(41) : see reference to
class template instantiation 'List<class GA_Driver *>' being compiled
d:\source\rars\rars\list.h(107) : warning C4284: return type for
'List<class GA_Driver *>::iterator::operator ->' is 'class GA_Driver
*const * ' (ie; not a UDT or reference to a UDT. Will produce errors
if applied using infix notation)
d:\source\rars\rars\ga_driver_pop.h(41) : see reference to
class template instantiation 'List<class GA_Driver *>' being compiled
race_manager.cpp
c:\program files\microsoft visual studio\vc98\include\new(35) : error
C2059: syntax error : 'string'
c:\program files\microsoft visual studio\vc98\include\new(35) : error
C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(35) : error
C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\new(36) : error
C2059: syntax error : 'string'
c:\program files\microsoft visual studio\vc98\include\new(37) : error
C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(37) : error
C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const
struct std::nothrow_t &)' : overloaded function differs only by return
type from 'void *(__cdecl *__cdecl op
erator new(void))(unsigned int)'
c:\program files\microsoft visual studio\vc98\include\new(35) :
see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\new(41) : error
C2059: syntax error : 'string'
c:\program files\microsoft visual studio\vc98\include\new(42) : error
C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(42) : error
C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,void
*)' : overloaded function differs only by return type from 'void
*(__cdecl *__cdecl operator new(void))(unsig
ned int)'
c:\program files\microsoft visual studio\vc98\include\new(35) :
see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\new(42) : error
C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\new(42) : error
C2065: '_P' : undeclared identifier
c:\program files\microsoft visual studio\vc98\include\memory(16) :
error C2059: syntax error : 'string'
c:\program files\microsoft visual studio\vc98\include\memory(17) :
error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\memory(17) :
error C2784: 'void *(__cdecl *__cdecl operator new(void))(unsigned
int,class std::allocator<`template-parameter257'> &)' : could not
deduce template argument for 'void *(__cdecl *)(u
nsigned int,class std::allocator<_Ty> &)' from 'void *(__cdecl
*)(unsigned int)'
c:\program files\microsoft visual studio\vc98\include\memory(17) :
error C2785: 'void *(__cdecl *__cdecl operator new(void))(unsigned
int,class std::allocator<`template-parameter257'> &)' and 'void
*(__cdecl *__cdecl operator new(void))(unsigned int
)' have different return types
c:\program files\microsoft visual
studio\vc98\include\memory(16) : see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\memory(17) :
error C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\memory(20) :
error C2954: template definitions cannot nest
d:\source\rars\rars\list.h(106) : warning C4284: return type for
'List<class GA_Driver *>::iterator::operator ->' is 'class GA_Driver **
' (ie; not a UDT or reference to a UDT. Will produce errors if applied
using infix notation)
d:\source\rars\rars\ga_driver_pop.h(41) : see reference to
class template instantiation 'List<class GA_Driver *>' being compiled
d:\source\rars\rars\list.h(107) : warning C4284: return type for
'List<class GA_Driver *>::iterator::operator ->' is 'class GA_Driver
*const * ' (ie; not a UDT or reference to a UDT. Will produce errors
if applied using infix notation)
d:\source\rars\rars\ga_driver_pop.h(41) : see reference to
class template instantiation 'List<class GA_Driver *>' being compiled
ga_driver_pop.cpp
d:\source\rars\rars\list.h(106) : warning C4284: return type for
'List<class GA_Driver *>::iterator::operator ->' is 'class GA_Driver **
' (ie; not a UDT or reference to a UDT. Will produce errors if applied
using infix notation)
d:\source\rars\rars\ga_driver_pop.h(41) : see reference to
class template instantiation 'List<class GA_Driver *>' being compiled
d:\source\rars\rars\list.h(107) : warning C4284: return type for
'List<class GA_Driver *>::iterator::operator ->' is 'class GA_Driver
*const * ' (ie; not a UDT or reference to a UDT. Will produce errors
if applied using infix notation)
d:\source\rars\rars\ga_driver_pop.h(41) : see reference to
class template instantiation 'List<class GA_Driver *>' being compiled
Error executing cl.exe.
Creating browse info file...
vc6_rars.exe - 34 error(s), 6 warning(s)
Any ideas?
Thanks,
Caroline
| |
| Stephen Howe 2006-03-08, 7:58 am |
| > I have a VC6 project to which I would like to use the std::vector
> class. When I include it i get a bunch of compile errors which are
> highlighted in the <new> header. These are as follows:
The error may be just before new header.
First error mentions string.
Are you using std::string?
Did you do #include <string> ?
Also did you do something like
std::vector<std::string>> v;
You need a space between the 2 ">>" as it will be mistaken for right-shift
operator.
Other than this, coud you present the smallest code that demonstrates the
error.
Thanks
Stephen Howe
| |
| cmiddlebrook@btinternet.com 2006-03-08, 7:58 am |
| No I'm not using strings at all. I'm not even using the vector yet -
only including it. If I comment out the include line all the problems
go away. It actually seems to be something to do with the <memory>
header, which is itself included by <vector> as I tried using my own
vector class that I wrote as an exercise some years ago and that
presented exactly the same errors (that also uses the <memory> header
for allocation)
Its difficult to post the smallest snippet of code that works because
this project is one that has been given to me for a piece of coursework
for University. I then have to modify it for the work i am doing. The
base project itself is quite large and doesn't use any STL.
Caroline
| |
| David Wilkinson 2006-03-08, 7:58 am |
| cmiddlebrook@btinternet.com wrote:
> No I'm not using strings at all. I'm not even using the vector yet -
> only including it. If I comment out the include line all the problems
> go away. It actually seems to be something to do with the <memory>
> header, which is itself included by <vector> as I tried using my own
> vector class that I wrote as an exercise some years ago and that
> presented exactly the same errors (that also uses the <memory> header
> for allocation)
>
> Its difficult to post the smallest snippet of code that works because
> this project is one that has been given to me for a piece of coursework
> for University. I then have to modify it for the work i am doing. The
> base project itself is quite large and doesn't use any STL.
>
> Caroline
>
Carloline:
Make a copy of the project and keep cutting pieces of it until the
problem goes away, or the error becomes obvious. This is a compile
problem, so the modified project does not have to run.
Or start the other end. Does the following code compile?
#include <vector>
int main()
{
return 0;
}
If it doesn't, there is something wrong with your VC installation.
David Wilkinson
| |
| Walter Eicher 2006-03-08, 7:58 am |
| Hi Caroline,
just a guess ;-)
Is your #include <string> behind
#ifdef _DEBUG
.....
#endif
then put your #include in front of this #define block.
HTH
Walter
On 8 Mar 2006 04:20:49 -0800, cmiddlebrook@btinternet.com wrote:
>No I'm not using strings at all. I'm not even using the vector yet -
>only including it. If I comment out the include line all the problems
>go away. It actually seems to be something to do with the <memory>
>header, which is itself included by <vector> as I tried using my own
>vector class that I wrote as an exercise some years ago and that
>presented exactly the same errors (that also uses the <memory> header
>for allocation)
>
>Its difficult to post the smallest snippet of code that works because
>this project is one that has been given to me for a piece of coursework
>for University. I then have to modify it for the work i am doing. The
>base project itself is quite large and doesn't use any STL.
>
>Caroline
| |
| Tom Widmer [VC++ MVP] 2006-03-08, 7:58 am |
| cmiddlebrook@btinternet.com wrote:
> No I'm not using strings at all. I'm not even using the vector yet -
> only including it. If I comment out the include line all the problems
> go away. It actually seems to be something to do with the <memory>
> header, which is itself included by <vector> as I tried using my own
> vector class that I wrote as an exercise some years ago and that
> presented exactly the same errors (that also uses the <memory> header
> for allocation)
>
> Its difficult to post the smallest snippet of code that works because
> this project is one that has been given to me for a piece of coursework
> for University. I then have to modify it for the work i am doing. The
> base project itself is quite large and doesn't use any STL.
Do any of the headers you are using contain "#define new <something>"?
Are you using MFC's debug new? From the errors posted, it looks like it
might be "macro pollution", where a #define in one header is destroying
another header.
What happens if you put #include <vector> first in the includes? If that
works, it suggests that I'm right.
Tom
| |
| Arnaud Debaene 2006-03-08, 7:03 pm |
| cmiddlebrook@btinternet.com wrote:
> Hi there,
>
> I have a VC6 project to which I would like to use the std::vector
> class. When I include it i get a bunch of compile errors which are
> highlighted in the <new> header. These are as follows:
>
><snip>
> Any ideas?
Is ther a macro redefining "new" somewhere in the code (MFC apps use this
trick in debug mode) ? If so, you should include the STL headers before the
macro definition.
Arnaud
MVP - VC
|
|
|
|
|