Odd Error

Started by
3 comments, last by Lurking 20 years, 1 month ago
Making a MFC Window w/ Opengl and my code generates an error: ============== c:\projects\ren\cwindow.cpp(14) : error C2143: syntax error : missing '';'' before ''PCH creation point'' Error executing cl.exe. ============== I cant seem to find what the hell it is looking for if you need code the error happens right before the constructor: ////CWindow //constructor and destructor CWindow::CWindow(){ Create(NULL,"Ren"); } Thanx if you can help me! - Lurking
- Lurking
Advertisement
HELP ME PLEASE
- Lurking
Read The Fscking Error Message!

Either you are missing a '';'' in your source file or have forgotten to declare a type.

Look BEFORE line 14 (e.g. at the end of a class declaration in an #include file)
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Most likely, you are missing '';'' in one of your headers. Are you doing this?
// Globals.h#include <stuff>void myfn();extern char mystring[];// main.cpp#include "globals.h"void myfn(){    ....} 

Make sure there are no syntax errors in globals.h (ie: missing '';''). Another way is this:
// Globals.h// No headersvoid myfn();extern char mystring[];// main.cpp#include <stuff>#pragma hdrstop#include "Globals.h"// Code 


This can give you other (more sensible) error message.

However, if you are using MFC, you should be doing this:
// stdafx.h#include <afxstuff.h>// No your stuff in this header// globals.h// put your stuff here// main.cpp (or whatever you have)#include "stdafx.h"#include "globals.h"// code 


Make sure stdafx.h is the first line in your .cpp files

It''s a good habit to have separate file for pch anyway (I always do). (ie: stdafx.h/cpp).

In case you don''t know: pch stands for precompiled header file. It''s when compiler compiles all those headers once and for all, and when you want to compile your .cpp, it just compiles your code, and not your code and all headers it uses. This results in faster (almost instant) build times for all .cpp files except the one used to create pch. If you use a blank file to create pch (take a look at stdafx.cpp), then all your files are built in no time when you change them. To convince yourself, compile a MFC project that includes a (insert large number here) of headers and a GL project that only uses gl.h and windows.h. Now change one line in a source file and recompile. MFC file should compile faster.

Hope I explained this clearly enough.
---visit #directxdev on afternet <- not just for directx, despite the name
you missing ; in your class header file
i had the same error it took me 5 hours to figur it out it's its like this

class
{
};// this semicolon is a must
then your .cpp file

This topic is closed to new replies.

Advertisement