This is a discussion on precompiled header file within the C++ Programming forums, part of the General Programming Boards category; Hi Mats, To me stdafx.h and stdafx.cpp are both empty, can you post yours please? Originally Posted by matsp Not ...
Stdafx.cpp:Code:// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Allow use of features specific to Windows XP or later. #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. #endif #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. #endif #define _HAS_TR1 1 #include <stdio.h> #include <tchar.h> #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif #include <afx.h> #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #ifndef _AFX_NO_OLE_SUPPORT #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #endif #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT #include <afxmt.h> #include <vector> #include <map> #include <fstream> #include <iostream> #include <cstdlib> #include <iomanip> #include <ctime> #include <cmath> #include <string> #include <list> #include <string> #include <new> //#include <stdint.h> #include <sstream> #include <Stuff\Requirements.h> // TODO: reference additional headers your program requires here
Far from empty if you ask me.Code:// stdafx.cpp : source file that includes just the standard includes // Help.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
In my hobby projects, I don't use precompiled headers for the very reason that I want to have all the includes needed for the project clearly visible in the C(++)-file, and not hidden inside some other file.
If both stdafx.cpp and stdafx.h are empty, then precompiled headers make absolutely no sense at all.
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
"turn off" you mean turn off pre-compiled header creation (/Yc) or turn off pre-compiled header using (/Yu)?
This conflicts with CornedBes's point in post #13, where he said the stdafx.h is empty. Any comments?
(BTW: I did search for stdafx.h and stdafx.cpp in my VC folder, and some of them are empty and some of them are not.)
I think whether or not pre-compiled header is used is decided by the compiler option /Yu, why do you think it is decided by whether the related header file is empty or not -- "the compiler sees the include of the empty stdafx.h as a directive to use stdafx.pch"