在MFC瘦身代码中,你或者已经发现有两个特殊的文件,StdAfx.h和tdAfx.cpp,它们仅仅是include头文件,什么也没做。如果你够细心,你还会发现在每个cpp文件最上面都include了StdAfx.h,这到底是干什么的呢?可以去掉吗?我们在Test1.cpp把#i nclude "stdafx.h"这一句去掉,编译发现出现这样的错误:fatal error C1010: unexpected end of file while looking for precompiled header directive。意思大概是找不到预编译指示。这个文件到底是干什么用的?其实wizard已经告诉我们答案了,答案就在 注释” 里面!什么?注释?不是已经删掉了吗?是的,就是在我们删掉的注释里面,所以,wizard所做的每一件事都是有道理的。那我们为什么要删掉注释?不就是为了能让你集中注意力看关键的东西嘛!还记得我们一开始备份的工程吗?打开看看:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
哦,原来它是用来包含一些标准的系统头文件以及在工程中一些经常用到的但又很少改动的头文件(到此看到我说的话,你应该体会到英语的重要性了)。再看StdAfx.cpp的注释:
// stdafx.cpp : source file that includes just the standard includes
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
哦,原来它是用来包含一些标准的系统头文件以及在工程中一些经常用到的但又很少改动的头文件(到此看到我说的话,你应该体会到英语的重要性了)。再看StdAfx.cpp的注释:
// stdafx.cpp : source file that includes just the standard includes