views:

203

answers:

3

I there a compiler option I could use in CC compiler to get the following code (which compiles fine in Visual C++)

std::vector<std::vector<double>> v2;

without the following error

Error: "," expected instead of ">>"

+15  A: 

Try this :

std::vector<std::vector<double> > v2; //give a space between two '>'

">>" is interpreted as the right shift operator and hence you get a compile time error.

This problem will be fixed in C++0x. Have a look here .

Prasoon Saurav
Yet one more reason I can't wait for C++0x to be finalized :)
ZoogieZork
I know why is it happening. The question is why it does compile smootly in VC++. Anyway - I am after a compiler option solution to make CC more VC++ compatible - because I could not change the original source.
Steve
I think its an MSVC++ extension.
Prasoon Saurav
@Steve: If you can't change the original source, and the original source is non-standard (as this is), you're in trouble. Compilers usually have options to enable non-standard extensions, but you can't rely on it for any given extension.
David Thornley
MSVC++ supports many non standard extensions(eg. : binding temporaries to non constant references)
Prasoon Saurav
+4  A: 

You need a space between the two greater-than signs:

std::vector<std::vector<double> > v2;

Otherwise, the ">>" is treated as a single token.

ZoogieZork
+4  A: 
std::vector<std::vector<double> > v2;

You need to add a space, other wise it will be interpreted as >> operator.

Raymond