1,105,578 Community Members

#include "stdafx.h"

Member Avatar
Paul Thompson
Veteran Poster
1,095 posts since May 2008
Reputation Points: 178 [?]
Q&As Helped to Solve: 189 [?]
Skill Endorsements: 3 [?]
 
-1
 

I was just wondering, in all of the code snippets i see there is no
#include "stdafx.h"
in them, but i cannot compile a program without it.

Is this a Microsoft Visual C++ that is the problem or am i just missing the point here?

Member Avatar
arshad115
Junior Poster in Training
65 posts since Nov 2008
Reputation Points: -3 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

'stdafx' is just the default name for the 'precompiled header directive'. The headers that included in stdafx.h are compiled once, and the information is saved to disk. When a file includes stdafx.h, the compiler just loads the precompiled data instead of re-parsing all the headers. Typically, more times is spent parsing header files than actually compiling your code, so using precompiled headers can dramatically speed up your build times.

Member Avatar
ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,090 [?]
Q&As Helped to Solve: 347 [?]
Skill Endorsements: 8 [?]
 
0
 

Some additions:
stdafx.h is Visual C++ specific pre-compiled headers artifact.
In precompiled headers mode VC++ ignores all lines before #include "stdafx.h". You may switch on/off this mode in Project Properties | Configuration | C/C++ | Precompiled Headers tab.

Member Avatar
Paul Thompson
Veteran Poster
1,095 posts since May 2008
Reputation Points: 178 [?]
Q&As Helped to Solve: 189 [?]
Skill Endorsements: 3 [?]
 
0
 

how do i get to project properties?

Member Avatar
ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,090 [?]
Q&As Helped to Solve: 347 [?]
Skill Endorsements: 8 [?]
 
0
 

how do i get to project properties?

There is a wonderful thing in VS IDE: the Main Menu (look at the top of the VS window). Select Project | projectname Properties or simply press Alt+F7 (if you can cope with a keyboard ;))...

Member Avatar
Paul Thompson
Veteran Poster
1,095 posts since May 2008
Reputation Points: 178 [?]
Q&As Helped to Solve: 189 [?]
Skill Endorsements: 3 [?]
 
0
 

Yeah, really now. Look i had a brain fade, im not a complete idiot. Found it, thanks for your info, it is very useful.

Cheers

Question Answered as of 5 Years Ago by ArkM and arshad115
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article