|
-
Mar 3rd, 2006, 10:26 AM
#1
Thread Starter
Hyperactive Member
stdafx.h, precompiled headers and windows.h
This is one of those things that I do not have a full grip of and have been ignoring for quite a while... what is the relationship between stdafx.h and precompiled headers?
I have had many times when I have needed to add #include <windows.h> and then later find that I cannot use this as this inclusion is apparently made in my stdafx.h (although this has nothing but just #include stdafx.h - including itself?!)..
The only things I know are (pls correct if I am wrong)...
+ if you want to use precompiled headers for a file you must include stdafx.h in the file
+ if you include a file with stdafx.h you cannot then have another file that includes <windows.h>
Any material to shed light would be great 
Cheers!
-
Mar 3rd, 2006, 12:49 PM
#2
Re: stdafx.h, precompiled headers and windows.h
Precompiled headers work like this:
1. a header is selected as the precompiled header, by default this is stdafx.h
2. all files that include that header as the first thing get to use the precompiled header.
3. a source file must be designated to generate the precompiled header, but iirc this can sometimes be done behind the scenes.
Including things in stdafx.h does not mean you are not allowed to include it elsewhere as well.
-
Mar 3rd, 2006, 04:08 PM
#3
Frenzied Member
Re: stdafx.h, precompiled headers and windows.h
i assume the real problem is that something didn't work, you saw 'include windows.h' and tried that.
if that's the case, know that with an MFC app you're already including a windows.h as you've figured out. you don't need to explicitly include it. the problem is that the windows.h your project is using predates whatever example you were looking at. so, it's simply time to begin using a newer version of windows.h
this is done by grabbing the latest windows/platform sdk (that's compatible with your IDE). once you install it, tell your IDE to use the newer files instead of the ones that came with the product.
you do this by digging around the IDE's options and add the paths to the appropriate subsection (make sure they are listed before the original paths):
Executable files: C:\Program Files\Microsoft Platform SDK\Bin
Include files: C:\Program Files\Microsoft Platform SDK\include
Library files: C:\Program Files\Microsoft Platform SDK\lib
Last edited by dis1411; Mar 3rd, 2006 at 04:19 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|