🔒 Locked
What is wrong with c++???
Advertisement
Original Post
Okay, here is the deal.
My program was working fine the night before. But right about 10 minutes ago, I changed functions from _putch to cout<< in about 3 lines of code and included the library concequently. No biggy, right? Well, when I compiled, I got a real suprize. My compiler is giving me a insteresting new error that I have never even heard about. For example, the set of code before the main:
#include "apstring.h"
int GetPlayerOption();
gives this error:
error C2143: syntax error : missing '';'' before ''PCH creation point''
pointing at the function decleration line int GetPlayerOption();...
And then this error is repeated for every single line of code in my driver.cpp file (the file with the code above). What in the world is this error???
Jonathan
The AP is closest.
PCH = PreCompiled Headers
Its complaining because it can''t find the header it wants for precompiled headers, typically this is named something like StdAfx.h in your project. Check your project settings and look for an option relating to precompiled headers--try turning it off.
PCH = PreCompiled Headers
Its complaining because it can''t find the header it wants for precompiled headers, typically this is named something like StdAfx.h in your project. Check your project settings and look for an option relating to precompiled headers--try turning it off.
quote:
Original post by Anonymous Poster
thats not the problem at all. at the very top of your program, add #include "stdafx.h" before everything else. tat will fix it.
Actually, that''s only a fix because of the PCH.
-~-The Cow of Darkness-~-

If you see the image I am online
i''ve had this happen. What I did was put all my #include statements into the file stdafx.h and #include stdafx.h in all the files instead of #including you''re files directly. I know, it''s a pain, hope that helps!
"apstring" sounds an awfully lot like Advanced Placement string for AP Computer Science A or AB in High School right? I took that class now 4 years ago, and we used metrowerks codewarrior, not VC++. Besides VC++ gives a different error message for PCH file errors.
I don''t know how to configure codewarrior, or how PCH''s work in it, but i do for VC++. Here''s my view on how they work in VC++ 6.0:
You have a common header file like "stdafx.h" with its associated "stdafx.cpp" file. Now stdafx.cpp has only 1 compile line: #include "stdafx.h". Why the seeming uselessness of this cpp file? It''s in your project settings.
In vc++ 6.0, right click on the cpp file (stdafx.cpp in this case) and goto settings. Under the C/C++ tab, there''s a pulldown box labeled categories. Put that to Precompiled Headers. Notice this: stdafx.cpp is set to create precompiled header file through file: stdafx.h. Any other files in your project will be set to: use precompiled header file though header: stdafx.h. That''s the importance of stdafx.cpp: It is always the first cpp file to be compiled because it is the file which creates the PCH file in the first place so the other cpp files can use it.
Now, it is also from this settings menu that you can turn off the use of PCH files for certain cpp files. You simply select the cpp file you want and select the option: not using precompiled headers. This way you don''t have to include the pch header at the top of every source file. This is vital when you have different projects that share common cpp and header files that cannot be modified.
I must say PCH files are awesome. My compile times on my game are down from 2 minutes to less than 15 seconds using them.
DreadID4
I don''t know how to configure codewarrior, or how PCH''s work in it, but i do for VC++. Here''s my view on how they work in VC++ 6.0:
You have a common header file like "stdafx.h" with its associated "stdafx.cpp" file. Now stdafx.cpp has only 1 compile line: #include "stdafx.h". Why the seeming uselessness of this cpp file? It''s in your project settings.
In vc++ 6.0, right click on the cpp file (stdafx.cpp in this case) and goto settings. Under the C/C++ tab, there''s a pulldown box labeled categories. Put that to Precompiled Headers. Notice this: stdafx.cpp is set to create precompiled header file through file: stdafx.h. Any other files in your project will be set to: use precompiled header file though header: stdafx.h. That''s the importance of stdafx.cpp: It is always the first cpp file to be compiled because it is the file which creates the PCH file in the first place so the other cpp files can use it.
Now, it is also from this settings menu that you can turn off the use of PCH files for certain cpp files. You simply select the cpp file you want and select the option: not using precompiled headers. This way you don''t have to include the pch header at the top of every source file. This is vital when you have different projects that share common cpp and header files that cannot be modified.
I must say PCH files are awesome. My compile times on my game are down from 2 minutes to less than 15 seconds using them.
DreadID4
quote:
Original post by Willm
The error is misleading and generally has nothing to do with PCHs. Its far more likely to be a parenthesis snafu in one of the earlier headers.
This post is misleading and generally has nothing to do with your problem. It is far more likely to be explained in another post regarding PCHs.
quote:
Original post by DreadID4
"apstring" sounds an awfully lot like Advanced Placement string for AP Computer Science A or AB in High School right?
BTW, you are right!
As for the semicolon after the } in the class, it is there, so it could not be the problem
Jonathan
[edited by - ageny6 on May 27, 2003 8:16:49 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement