Does Vector is not supported by VC++ 6.0??

A

Andrew Koenig

Ram Laxman said:
I have used vector in the VC++ compiler. I have included

#include <string>
#include <algorithm>
#include <vector>

std::vector<int> field;
std::vector <int>::size_type i;


test.cpp(135) : error C2653: 'std' : is not a class or namespace name
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '<'
error C2653: 'std' : is not a class or namespace name

There are several bugs in VC++ 6.0 that affect programs that use vector and
related classes.

Before you do anything else, be sure that the latest service pack for VC++
6.0 (which I think is Service Pack 4) is installed, as it fixes a number of
those bugs.

One bug that is not fixed, and might be related to your problem, is this:

using std::vector;
vector<int>::size_type i;

This code should work, but doesn't work in VC++ 6.0; instead, you have to
say

std::vector<int>::size_type i;

I *think*, but am not certain, that even this latter version of the code
requires Service Pack 4.
 
D

Deming He

David Harmon said:
Still wrong. Of course I have tried it, many times.
The issue and the fix are well-known, e.g. recently
http://groups.google.com/[email protected]
http://groups.google.com/groups?selm=rMYMb.47226$xy6.116719@attbi_s02

By the way, I notice the poster's error message refers to line 135, and
he only posted 5 lines of code, therefore he is lying to us about what
the actual code is that produced the message.
I think you're right on this. The code showed by OP could be very possibly
not the source of compile errors. In some other place(s) of OP's code,
std::vector used but <vector> not include'd.
 
M

Mike Wahler

Michael Groys said:
Just inserting one space doesn't help.
Try it if you don't believe.

It works just fine with VC6, as does the OP's posted code.

-Mike
 
M

Mike Wahler

Michael Groys said:
I didn't do any search in Google concerning this problem, but I did
write programs in VC6 and I got an error.

OK post the *exact* code you tried, and the exact text of any error
messages.

-Mike
 
M

Mike Wahler

E. Mark Ping said:
You don't know what you're talking about. And you apparently are too
stubborn or arrogant to realize that you might be wrong (and in this
case you *are* wrong).

This is a known ambiguity of the standard,


What ambiguity?
where any
A<B<type> > construct will only compile with the two '>' separated,
typically by whitespace.


That's the *only* way to 'separate' them.

'>' and '>>' are two separate tokens.
Refrain from giving advice if your own
ignorance is greater than the OP.

:)

-Mike
 
M

Mike Wahler

Andrew Koenig said:
There are several bugs in VC++ 6.0 that affect programs that use vector and
related classes.

Before you do anything else, be sure that the latest service pack for VC++
6.0 (which I think is Service Pack 4) is installed, as it fixes a number of
those bugs.

One bug that is not fixed, and might be related to your problem, is this:

using std::vector;
vector<int>::size_type i;

This code should work, but doesn't work in VC++ 6.0; instead, you have to
say

std::vector<int>::size_type i;

Yes, I've run into that myself.
I *think*, but am not certain, that even this latter version of the code
requires Service Pack 4.

<OT info>
Last Service Pack for VC6 is SP5, dowloadable from msdn.microsoft.com,
or can be obtained on CD for a nominal shipping fee.
</OT info>

-Mike
 
D

David Harmon

I think you're right on this. The code showed by OP could be very possibly
not the source of compile errors. In some other place(s) of OP's code,
std::vector used but <vector> not include'd.

Missing semicolon on preceding line, who knows? Could be anything.
 
E

E. Mark Ping

It's not an ambiguity. >> is one token, not two.

Poor wording on my part--I was aware that the space was necessary to
make it two tokens instead of one. Thanks for the correction.
 
R

Ricky Lung

You have a "space" between std::vector and <int>
std::vector <int>::size_type i;

Ram Laxman said:
I have used vector in the VC++ compiler. I have included

#include <string>
#include <algorithm>
#include <vector>

std::vector<int> field;
std::vector <int>::size_type i;


test.cpp(135) : error C2653: 'std' : is not a class or namespace name
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '<'
error C2653: 'std' : is not a class or namespace name


Does anybody know what is the problem??

Regards
Bubunia


~ Let us linux ~
 
C

Christoph Rabel

Ricky said:
You have a "space" between std::vector and <int>
std::vector <int>::size_type i;

No. Spaces dont matter.

std :: vector <int> :: size_type t;

compiles fine with VC6.

And please dont toppost.

Christoph
 
M

Michael Groys

Mike said:
OK post the *exact* code you tried, and the exact text of any error
messages.

-Mike

Ok, SP 4 indeed fixed this problem, but in initial Version of VC 6

the following code, didn't work

class MyClass: public MyClassT<vector<int> >
{
public:
// with any number of spaces on the next line.
MyClass(int i): MyClassT<vector<int> > (i)
{...}
};

And this has nothing to do with standard.

Don't worry be happy, Michael
 
M

Mike Wahler

Michael Groys said:
Ok, SP 4 indeed fixed this problem, but in initial Version of VC 6

Note that the latest patch for VC6 is SP5
the following code, didn't work

class MyClass: public MyClassT<vector<int> >
{
public:
// with any number of spaces on the next line.
MyClass(int i): MyClassT<vector<int> > (i)
{...}
};

And this has nothing to do with standard.

Your problem had to do with a broken compiler.

But we do use the standard to determine code correctness.
We obviously can't use a compiler, because, as you've seen,
sometimes they're broken. (Look up "quality of implementation").

-Mike
 
M

Michael Groys

Mike said:
Your problem had to do with a broken compiler.

But we do use the standard to determine code correctness.
We obviously can't use a compiler, because, as you've seen,
sometimes they're broken. (Look up "quality of implementation").

-Mike
You are right, but I was talking about concrete problem that was in VC 6
and not about the standard.
Thats all.

BTW does somebody knows how to determine what SP of VC is installed.
In Help->About this information doesn't appear.
Michael
 
C

Carl Muller

I have used vector in the VC++ compiler. I have included

#include <string>
#include <algorithm>
#include <vector>

std::vector<int> field;
std::vector <int>::size_type i;


test.cpp(135) : error C2653: 'std' : is not a class or namespace name
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '<'
error C2653: 'std' : is not a class or namespace name


Does anybody know what is the problem??

Regards
Bubunia

Most likely you have an error in one of the header files or
declarations you are including before line 135 that you have omitted,
for example defining a class or an enum without putting a semicolon
after it.
 
M

Mike Wahler

Michael Groys said:
You are right, but I was talking about concrete problem that was in VC 6
and not about the standard.
Thats all.

Right, you were dealing with a compiler problem, not a language issue.
Of course, it took asking here to determine that (iow you needed to
know if the compiler was implementing the language correctly). But
once that has been determined (compiler problem), that makes your issue
off-topic here.
BTW does somebody knows how to determine what SP of VC is installed.
In Help->About this information doesn't appear.

You're asking another OFF TOPIC question. We discuss ONLY the (ISO)
standard) language here.

Ask about Visual C++ in Visual C++ newsgroups. You can find them
by visiting www.msdn.microsoft.com/newsgroups

-Mike
 
A

Andy Buchanan

I didn't do any search in Google concerning this problem, but I did
write programs in VC6 and I got an error.
Did you try it in VC or just in google?

From a recent vc++6 project of mine.

std::vector< std::vector<BeatErrorData> > m_SubbandBPMScores;

No Error. Maybe you need a service pack or 3?

R.
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,134
Latest member
Lou6777736
Top