Solved

stdafx.h ?

Posted on 2006-06-23
4
1,167 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now