xcdemon05
xcdemon05

Reputation: 1432

Visual Studio not recognizing certain classes

I keep getting the error:

error C2146: syntax error : missing ';' before identifier 'mCameraFrame'

for the line of code:

Frame mCameraFrame;

So clearly my frame class isn't being found somehow. I have the frame.h header file (which defines the Frame class) directly included in this file. Why doesn't visual studio recognize it?

Upvotes: 1

Views: 2243

Answers (2)

xcdemon05
xcdemon05

Reputation: 1432

Figured I'd report back to anyone that's interested. The problem was that the Frame class that was supposed to be definining mCameraFrame was in a different namespace, so all I had to do was "using namespace ....;". Doh! :P

Upvotes: 0

David Schwartz
David Schwartz

Reputation: 182893

The error is coming from previous lines of code, possibly in a header file.

For example:

struct foo
{
    int a;
}

Frame mCameraFrame;

Notice the missing ; after the }? That makes the Frame legal as an instance of the structure, but now there's a missing ; before mCameraFrame, resulting in the kind of error you reported.

The compiler can't report a missing ; after the } because it has no way to know there's supposed to be one there, since the Frame that comes after it is perfectly legal.

It's not unusual for a single missing ; or missing } to result in errors reported many lines later than the actual problem, sometimes hundreds of them.

Upvotes: 3

Related Questions