Skip to main content
gamedev.net
🔒 Locked

What is wrong with c++???

Started by ageny6 May 26, 2003 at 6:31 PM 16 replies 1.1k views
Original Post
ageny6
ageny6
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
My signature used to suck. But it's much better and more accurate now.
Rob Loach
Rob Loach
Check out "apstring.h". It might be in there.



Rob Loach
Current Project: Go Through Object-Oriented Programming in C++ by Robert Lafore

"Do or do not. There is no try."
- Yoda
Rob Loach [Website] [Projects] [
Willm
Willm
Do you have a carriage return after the inclusion guard in "apstring.h"?
Rob Loach
Rob Loach
Also, try using:
#include <apstring.h> 

I doubt it''ll help, but might as well try.



Rob Loach
Current Project: Go Through Object-Oriented Programming in C++ by Robert Lafore

"Do or do not. There is no try."
- Yoda
Rob Loach [Website] [Projects] [
antareus
antareus
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.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
cowsarenotevil
cowsarenotevil
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
-~-The Cow of Darkness-~-
perfectly_dark
perfectly_dark
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!
Oluseyi
Oluseyi
Listen to antareus. He''s the only one who completely understands what he''s saying. Oh, and learn your IDE. It often has requirements that extend beyond the language (like PCHs).
antareus
antareus
This thread is annoyingly ironic because I used to know how to set up PCH properly, but now I don''t. I find the requirement that the PCH header must be at the top of every source file rather asinine.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
DreadID4
DreadID4
"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
Willm
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.
ageny6
ageny6
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.


The example I gave was the very first header in the driver program!!! That cannot be it.



Jonathan
My signature used to suck. But it's much better and more accurate now.
sjelkjd
sjelkjd
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.
billybob
billybob
i get that error on every function if i forget a semicolon on the last line of a header (usually the one after the } for a class)
ageny6
ageny6
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]
My signature used to suck. But it's much better and more accurate now.
ageny6
ageny6
OMG, it worked. I deactivated the precompile option for the driver file that was getting the PCH errors, and it worked like a charm. Thanks everyone!

Jonathan
My signature used to suck. But it's much better and more accurate now.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.