我是一个MFC的初学者,用MFC的应用程序向导生成一个单文档程序之后,我发现了基础不明白的地方:
开头:
    #if !defined(AFX_SINGLE_H_317D6D27_36F4_11D3_A79D_52544C1C8281_INCLUDED_)
    #define AFX_SINGLE_H_317D6D27_36F4_11D3_A79D_52544C1C8281_INCLUDED_
    这是什么意思?一连串数字和字母!
还有:
/*1*/    #if _MSC_VER>1000
/*2*/    #pragma once
/*3*/    # end if
/*4*/    #ifndef _AFXWIN_H_
/*5*/        #error include 'stdafx.h' before including this file for PCH
/*6*/    #end if
    第五句是不是注释,如果不是,怎样用语法解释?pragma是什么意思?另外,是不是在c语言里的头文件,到了这里就写作 _AFXWIN_H_,前后加上_,中间的点换成_?
帮小弟一把!

解决方案 »

  1.   

    1. 后门,防止重复include该头文件。
    2. #ifndef _AFXWIN_H_...条件编译,保证需要的头文件先被include
    3. pragma,看msdn
      

  2.   

    同意一楼的
    建议看看《深入浅出mfc》
      

  3.   

    /*1*/    #if _MSC_VER>1000 //如果VC的版本高于1.0,_MSC_VER是编译器预定义的宏
    /*2*/    #pragma once
    #pragma once
    Specifies that the file will be included (opened) only once by the compiler in a build. This can reduce build times as the compiler will not open and read the file after the first #include of the module.
    因为VC支持预编译头文件,所以如果相应头文件没有修改,只需编译一次。
    /*3*/    # end if
    /*4*/    #ifndef _AFXWIN_H_ //_AFXWIN_H_是在afxwin.h中定义的宏,如果没有定义,就是没有包含afxwin.h头文件,而stdafx.h默认包含了该头文件,所以该宏没有定义可以认为没有包含stdafx.h头文件。
    /*5*/        #error include 'stdafx.h' before including this file for PCH //出现编译错误:include 'stdafx.h' before including this file for PCH,提醒用户没有包含stdafx.h头文件。
    /*6*/    #end if
      

  4.   

    这些东西你可以不管,
    不会影响直接写程序,
    是mfc框架特有的。