did you forget to add stdafx.h problem

来源:互联网 发布:阿里云上线时间 编辑:程序博客网 时间:2024/05/21 17:46

1. in vs environment program, if you don't add stadfx.h file to *.cpp file,the compiler will  recommend this error.
    the solution for this err is :

  property/c/C++/Precompileed Headers/Precompiled Header to "not Using Precompiled Headers".


2. stdafx.h文件介绍:

由于Windows和MFC的include文件都非常大,并且每个.CPP文件都包含相同的include文件,为每个.CPP文件都重复处理这些文件就会非常不值得,为了节省编译时间,AppWizard在生成工程文件时,会自动生成stdafx.h以及stdafx.cpp文件。在编译过程中VisualC++和AppWizard所做的工作为:

   (1)AppWizard生成文件stdafx.h,该文件包含了当前工程文件需要的所有的MFCinclude文件,这一文件随着选择的选项尔变化;
   (2)AppWizard然后生成stdafx.cpp,这个文件通常都是一样的;
   (3)AppWizard生成工程文件,此时第一个被编译的文件就是stdafx.cpp文件;
   (4)VisualC++编译stdafx.cpp文件时,它将结果保存在一个名为stdafx.pch的文件里。(扩展名pch表示预编译头文件。)
   (5)VisualC++编译其它剩余的.cpp文件时,它将会使用stdafx.pch文件。VisualC++不再分析编译Windowsinclude文件,除非stdafx.cpp或stdafx.h这两个文件又有了新的变化。


stdafx.pch文件是编译之后一个非常大的文件,此文件中包含了大量的函数符号信息。


参考信息:http://blog.csdn.net/zhang_hui_cs/article/details/7541583


0 0