大家看下一下代码,其中#include <mmsystem.h>这个头文件是我自己加的,其他的都是对话框工程自动生成的,这个#include <mmsystem.h>只能放在#ifndef _AFX_NO_AFXCMN_SUPPORT这句话的顶头位置,放弃他位置均报错。看不出二者有什么关联啊,希望有高手能出来解释下原因。谢谢
#if !defined(AFX_STDAFX_H__D97D07B0_CE65_4B8A_8ADD_FB04B9437C17__INCLUDED_)
#define AFX_STDAFX_H__D97D07B0_CE65_4B8A_8ADD_FB04B9437C17__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
#include <mmsystem.h>
#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__D97D07B0_CE65_4B8A_8ADD_FB04B9437C17__INCLUDED_)

解决方案 »

  1.   

    #include <mmsystem.h>里面您都调用了什么?
    这个应该跟您<mmsystem.h>里的内容有关系
      

  2.   

    那就放在#ifndef _AFX_NO_AFXCMN_SUPPORT 前边,文件包含很有讲究的,你这样可能是因为你#include <mmsystem.h>头文件里面定义了跟
    #ifndef _AFX_NO_AFXCMN_SUPPORT 
    #include <afxcmn.h> // MFC support for Windows Common Controls 
    #endif // _AFX_NO_AFXCMN_SUPPORT 
    相关的东西,如果你放在后边可能引起重复包含,这样会出错的,系统在编译的时候会把头文件内容嵌到源文件里面去,一旦你重复包含就会报错,你可以用#pragma once 来取消重复包含的错误。
    还有头文件包含有时候还有先后的关系,有时候如果先调一个头文件,在调另一个,那么这两个头文件就必须有先后关系