Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stdafx.h: When do I need it?

People also ask

Why do I need Stdafx h?

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.

What does Stdafx stand for?

h (named stdafx. h before Visual Studio 2017) is a file generated by the Microsoft Visual Studio IDE wizard, that describes both standard system and project specific include files that are used frequently but hardly ever change. The afx in stdafx. h stands for application framework extensions.

Are precompiled headers worth it?

The advantage of precompiled headers is that the huge system library header files and other files that do not change at all or infrequently only have to be parsed once per build. As all C compilers (that I know of) work on every .


If you don't want to use precompiled headers, then there is no point to using a standard include file - this will slow down the build for every file that includes it and cause them to include extra stuff that they do not need. Get rid of it and just include the headers they need.


You can use pre-compiled headers (which are a good thing) without using stdafx.h (I abominate it too). I've only got access to VC++ 6.0 but in that go to Project Settings|C/C++|Precompiled Headers and select "automatic use of precompiled header" but leave the "compiled through" box empty.


stdafx.h is just another header file. If you feel that you don't need it then feel free to not include it and remove it from the project.

However it's quite typical to have a file like stdafx.h exactly for precompiled headers to work and to not include all the stuff manually in each source file.


Even without pre-compiled headers stdafx.h could be handy as it groups header includes and definitions common for all files.

You can of course choose to repeat all these definitions in every file. stdafx.h is not strictly necessary.