请问stdafx.h是C里面的标准库么,有什么作用???
请问stdafx.h是C里面的标准库么,有什么作用??? 问题点数:0、回复次数:11Top
1 楼260005065(宁独遗与世,亦当皓首穷经,但有所得,无悔无怨。)回复于 2004-12-02 07:08:31 得分 0
不是的,它一般用在MFC中。
由于MFC体系结构非常大,包含许多头文件,如果每次都编译的话比较费时。因此,我们把常用的MFC头文件都放在stdafx.h中,如afxwin.h、afxext.h、afxdisp.h、afxcmn.h等,然后让stdafx.cpp包含这个stdafx.h文件。这样,由于编译器可以识别哪些文件已经编译过,所以stdafx.cpp就只编译一次,并生成所谓的预编译头文件(因为它存放的是头文件编译后的信息,故名)。如果读者以后在编程时不想让有些MFC头文件每次都被编译,也可以将它加入到stdafx.h中。采用预编译头文件可以加速编译过程。
Top
2 楼nastar(阿门)回复于 2004-12-02 08:05:27 得分 0
它是MFC的标准库。他里面包含使用MFC需要的基本库。
典型的stdafx.h内容如下:
#if !defined(AFX_STDAFX_H__EFA7668A_8996_44A2_AB9E_B78C26B10722__INCLUDED_)
#define AFX_STDAFX_H__EFA7668A_8996_44A2_AB9E_B78C26B10722__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__EFA7668A_8996_44A2_AB9E_B78C26B10722__INCLUDED_)
Top
3 楼pcboyxhy(-273.15℃)回复于 2004-12-02 08:10:20 得分 0
不是C的一部分,
MFC都不算C的一部分。
可以参考ISO标准Top
4 楼bylmy()回复于 2004-12-02 20:20:14 得分 0
为什么我的VC编译时显示无法找到stdfax.h文件?是不是VC的安装问题,别人机子上正常?Top
5 楼Qystone(小石头)回复于 2004-12-02 20:29:06 得分 0
stdfax.h?? 是不是搞错了stdafx.hTop
6 楼bylmy()回复于 2004-12-02 20:44:43 得分 0
对,不好意思,是我打错了。就是Stdafx.h,总是说找不到?为什么?是不是我的VC装的有问题Top
7 楼bylmy()回复于 2004-12-02 20:47:37 得分 0
e:\c\2_3\2_3.cpp(160) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.Top
8 楼jasmineily(学习中)回复于 2004-12-02 21:04:47 得分 0
在2_3.cpp里最前面加上一行#include "stdafx.h"
或在工程选项中去掉这个文件的鼠标拖动预编译头文件这个选项Top
9 楼gongsunde(碧海晴天)回复于 2004-12-02 21:37:43 得分 0
换个vc 盘试一试,或者从别人那里拷贝一个过来看行不,"stdafx.h"里没有实际内容Top
10 楼bylmy()回复于 2004-12-03 02:52:21 得分 0
已经重新装了VC,但是这次出现如下错误:
233.cpp
c:\program files\microsoft visual studio\myprojects\233\233.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/233.pch': No such file or directory
请问又是为什么呢?Top
11 楼jasmineily(学习中)回复于 2004-12-03 13:05:32 得分 0
rebuild all或删掉debug目录下所有文件再编译Top




