unexpected class??

Started by
4 comments, last by merwin 22 years, 4 months ago
Hello If I try to compile my program (with visual c++ 6)I get the following errors serveral times: error C2236: unexpected ''class'' error C2143: syntax error : missing '';'' before ''PCH creation point'' I can''t find any error in my source related to this..
Advertisement
looks like two things:
- you''re defining the files to use pre-compiled headers, but your pre-compiled header is not the first #include in the file.
- you might be calling your files something.c, which makes MSVC compile them as C files, not as C++ files. Rename them something.cpp.
sounds like your trying to define a class before including the PreCompiled Header

ie make sure that the first line of code in all your cpp files is

#include "StdAfx.h"

that should do the trick!!

Paul.

Edited by - Spider_In_A_Web on October 30, 2001 11:33:34 AM
I got this exact message a couple days ago, and it turned out to be caused by a missing semi-colon, of all things. I know VC++ has a habit of issuing error messages that aren''t related to the actual error, so it may just be me...

''Nuff said. I''ll enjoy watching you live, demon.
CoV
Mayrel: that''s a good point. The parser separates statements by braces, semicolons or other syntax-dependent separators. Therefore, it''s always a good idea to handle errors from the top of the file - they often clear up errors further down.
Sorry to revive an old thread, but this problem has been bugging me lately, and I hope some more light can be shed upon it. I get the same "unexpected class" error, but this time it''s in the header, not the source. I have no errors before this one, and for some reason, even when I only include the h file once (with multiple inclusion guards), it still gives me "unexpected class"

quote:Spider_In_A_Web
make sure that the first line of code in all your cpp files is #include "StdAfx.h"


Erm.. what if I don''t have any "StdAfx.h" file?

Anyway, what on earth could the problem be? I declare my class like this:

class CRenderer
{
stuff
};

so what is so Unexpected about it?

Anye help would be appreciated,

freshya

This topic is closed to new replies.

Advertisement