views:

455

answers:

3

my compiler throws

error: expected ';' before '<' token

on this line of code:

std::vector< std::vector<int> > data;

What's real weird is that I compiled this earlier today on my mac with g++ on the command line and now i'm trying to compile in xCode on the same mac (which i assume also uses g++) and it throws this error.

What am I missing here?

EDIT: I knew it had to be right in front of me, but there was nothing else wrong in the file. it was the semicolon at the end of an included class. Thanks.

A: 

Try #include <vector>. Different compilers or versions of the same compiler do different things with the STL includes.

Dima
+2  A: 

Possibly #include <vector>, or possibly something is wrong in the code that comes before that line. It is very difficult to say without seeing the entire code.

Tronic
+4  A: 

Probably you are missing a semicolon at the end of what's on the previous line.

If you have no code before that line, then it is a missing semicolon at the end of one of your included header files.

For example you can reproduce this error using:

#include <vector>
class C
{

}

std::vector< std::vector<int> > data;
Brian R. Bondy