Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 25th, 2005, 3:35 PM   #1
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
"stdafx.h"

just started using visual studio, precisely what is this library?

dawei...?
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Sep 25th, 2005, 4:11 PM   #2
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
stdafx.h is the precompiled header file.

"The precompiled header file should include the big header files which slow down your builds. The most obvious candidate is windows.h, the 800 lb gorilla of the header file world. Other possible candidates are STL header files. "

I found a good article on VC++ compiling techniques: Fractal eXtreme

MSDN:
Quote:
Precompiled Header FilesSee Also
File Types Created for Visual C++ Projects
These files are used to build a precompiled header file Projname.pch and a precompiled types file Stdafx.obj.

These files are located in the Projname directory. In Solution Explorer, Stdafx.h is in the Header Files folder, and Stdafx.cpp is located in the Source Files folder.

Stdafx.h An include file for standard system include files and for project-specific include files that are used frequently but are changed infrequently.

You should not define or undefine any of the _AFX_NO_XXX macros in stdafx.h; see the Knowledge Base article "PRB: Problems Occur When Defining _AFX_NO_XXX". You can find Knowledge Base articles in the MSDN Library or at http://search.support.microsoft.com/
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Old Sep 25th, 2005, 5:16 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Personal perspective: I normally only write small things. I remove (or set up so as not to incur) the stdafx things and turn off precompiled headers. Even when using windows.h. My compile/links probably take 5 seconds, tops. It's nothing like the doorstops we used to be saddled with, where you started a compile and took a 30-minute break.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 26th, 2005, 6:40 PM   #4
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
I wonder how long it took for Microsoft to compile one of their operating systems or office programs.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Sep 26th, 2005, 6:44 PM   #5
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Why don't you try to compile the linux source to get an idea , it can probably take days to build and compile everything.
OpenLoop is offline   Reply With Quote
Old Sep 27th, 2005, 12:24 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Quote:
Originally Posted by nnxion
I wonder how long it took for Microsoft to compile one of their operating systems or office programs.
They do nightly builds, if I remember correctly. Apparently, if your code breaks the build, you get called in at 2am to fix it.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 28th, 2005, 1:38 AM   #7
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
here's another dumb question then...why does the compiler throw a fit if i remove it?
code
int main(){
	return 0;}

resulting error
Quote:
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
edit 2 minutes later...
Quote:
(by dawei)...turn off precompiled headers...
this is it isn't it?

edit 6 minutes later...
how?
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Sep 28th, 2005, 7:23 AM   #8
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 3 Narue is on a distinguished road
>how?
Start out with an empty project to begin with.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Sep 28th, 2005, 12:49 PM   #9
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
what i meant is i just went through about 40 menus in the options dialog, and was wondering if anyone knew "off the top of their head".

i'm going to ask microsoft.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Sep 28th, 2005, 1:31 PM   #10
Animatronic
Programmer
 
Join Date: Jun 2005
Posts: 99
Rep Power: 4 Animatronic is on a distinguished road
I think its pritty stupid that you need #include "stdafx.h" in order to compiled when precompile headers are turned on, I mean couldn't the compiler add it if it cant compile without it .

btw, stdafx.h its the default name for the precompiled header, you can change it.

As for taking them off:

For a project-

Right click on project> Properties>c/c++>Precompiled Headers>Use precompiled headers> set to not using precompiledd headers.

You can also do that for a single cpp file by right clicking on it (good for excluding third party utilities).
Animatronic is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:19 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC