Solved

stdafx.h ?

Posted on 2006-06-23
4
1,177 Views
Last Modified: 2006-11-18
I'm using Visual Studio 2005 Pro, and when I create a Win32 Console app [without including the stdafx.h header], I get the following compilation error:

fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?

When I do include this header, it all compiles fine.

But, why is VS insisting on it? All stdafx.h contains on my comp, is:

#pragma once
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <tchar.h>

What's so special about it?


Thanks
0
Comment
Question by:InteractiveMind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 125 total points
ID: 16972601
'StdAfx.h' is VC's default setting to generate it's precompiled headers for. You can change the file's name to one different from that or turn off the precompiled header feature completely in your Project settings under 'C++|Precompiled Heades'. However, when your projects grow larger, turning that off might have a big impact on compile speed.
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 16972627
Could you please give me a brief explanation of what precompiled headers are?

Thanks
0
 
LVL 86

Expert Comment

by:jkr
ID: 16972661
'Precompiled headers' basically are already parsed headers that are stored in binarily in .pch files to speed up compilation. If these are present, the compiler can read the information directly from them instead parsing the header files again. This is particularly useful for e.g. Windows SDK headers, since they are quite large and hardly ever change.
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 16972676
Oh right, pretty self explanatory I guess - hehe
Makes great sense.

Thank you. :D
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question