C++ map: expected initializer before ‘<’ token
I'm getting this error in a header file:
error: expected initializer before ‘<’ token
class MyEntity;
typedef std::map<uint16,MyEntity*> myList_t;
I figured it's not seeing the ma开发者_Python百科p include, but at the top of that header file is:
#include <list>
#include <map>
In another header file:
typedef unsigned int uint32;
Any ideas?
g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
There was a macro named map that was causing a conflict.
In your actual code (not your simplified example) you are probably missing a ;
from the end of the line before the typedef
. This is usually what it means when I get that kind of cryptic error and I can almost reproduce your message by putting another underminated typedef
above it:
q.cc:8: error: expected initializer before 'typedef'
My first guess was that class MyEntity
was a full definition (not a forward declaration) and was missing the ;
but I get a slightly different error for that.
精彩评论