I have two include file headers
#include "stdafx.h"
#include "psapi.h"
However it gives a cannot open source file "stdafx.h" compile time error. I am using Visual Studios 2010. Is "stdafx.h" even necessary? I think so because the program cannot compile if i take it away.
To turn it off, open the Visual C++ Component Properties dialog and in the tab "Includes" delete the text in the "Initial Source Includes". Another possibility is to create an empty "stdafx. h" file. For more information about precompiled header files, refer to the Microsoft knowledge base.
"Stdafx. h" is a precompiled header.It include file for standard system include files and for project-specific include files that are used frequently but are changed infrequently. which reduces compile time and Unnecessary Processing.
pch stands for precompiled header. In computer programming, a precompiled header is a (C or C++) header file that is compiled into an intermediate form that is faster to process for the compiler.
The file stdafx.h is usually used as a precompiled header file. Precompiled headers help to speed up compilation when a group of files in a project do not change.
@Benoit: My Visual Studio (2010) reports something (at least a warning) when stdafx.h is not the first include. – Vlad Jun 1 '11 at 15:07 1 Note: if any onefile includes stdafx.h, then they all should. I had problems where only one file (from 3rd party) used it, so I had to include it in all my header files. I prefer not to use it.
To turn it off, open the Visual C++ Component Properties dialog and in the tab "Includes" delete the text in the "Initial Source Includes". Another possibility is to create an empty "stdafx.h" file.
The proper way of adding stdafx.h is by mentioning use pre-compiled header file in your Project settings. thank you so much ! it's all now clear to me ! You are welcome! No, it does not speed up the application, and it is not added by the compiler.
Visual Studio uses it for "precompiled headers" feature. If you are not experienced with Visual Studio, I would recommend to keep the stdafx.h in the project.
And of course, if you #include it, you ought to have it.
stdafx.h is used for precompiled headers. It is not necessary, but disabling the compiler feature can be a little tricky if you have never done it before. If you have it, then you must compile 'stdafx.cpp' before compiling anything else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With