What is wrong with c++???

Started by
16 comments, last by ageny6 20 years, 11 months ago
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
Advertisement
"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
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.
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.
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.
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)
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.
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.

This topic is closed to new replies.

Advertisement