seventeen
seventeen

Reputation: 1531

error: expected ';' before '<' token

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.

Upvotes: 0

Views: 11874

Answers (3)

Brian R. Bondy
Brian R. Bondy

Reputation: 347216

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;

Upvotes: 5

Tronic
Tronic

Reputation: 10430

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.

Upvotes: 3

Dima
Dima

Reputation: 39389

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

Upvotes: 0

Related Questions