A file named stdafx.h
is automatically generated when I start a project in Visual Studio 2010. I need to make a cross-platform C++ library, so I don't/can't use this header file.
What is stdafx.h
used for? Is it OK that I just remove this header file?
This question is related to
visual-studio
visual-studio-2010
visual-c++
cross-platform
stdafx.h
I just ran into this myself since I'm trying to create myself a bare bones framework but started out by creating a new Win32 Program option in Visual Studio 2017. "stdafx.h" is unnecessary and should be removed. Then you can remove the stupid "stdafx.h" and "stdafx.cpp" that is in your Solution Explorer as well as the files from your project. In it's place, you'll need to put
#include <Windows.h>
instead.
"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.
Precompiled Header stdafx.h is basically used in Microsoft Visual Studio to let the compiler know the files that are once compiled and no need to compile it from scratch. You can read more about it
http://www.cplusplus.com/articles/1TUq5Di1/
https://docs.microsoft.com/en-us/cpp/ide/precompiled-header-files?view=vs-2017
It's a "precompiled header file" -- any headers you include in stdafx.h are pre-processed to save time during subsequent compilations. You can read more about it here on MSDN.
If you're building a cross-platform application, check "Empty project" when creating your project and Visual Studio won't put any files at all in your project.
Source: Stackoverflow.com