#if !defined(AFX_MAINFRM_H__A243FFFA_F465_4615_B3E7_F1B0B385CF0E__INCLUDED_)#define AFX_MAINFRM_H__A243FFFA_F465_4615_B3E7_F1B0B385CF0E__INCLUDED_
防止头文件被重复include#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
只编译一次上面两个是不是作用重复了?

解决方案 »

  1.   

    不是作用重复了!
    #if !defined(AFX_MAINFRM_H__A243FFFA_F465_4615_B3E7_F1B0B385CF0E__INCLUDED_)#define AFX_MAINFRM_H__A243FFFA_F465_4615_B3E7_F1B0B385CF0E__INCLUDED_
    防止头文件被重复include
    Yes!use this tricky to prevent a header file to include once!but it doesn't mean
    it is also compiled once too!
    Suppose our project contains two seperate *.cpp files:
    file1.cpp(and file1.h)
    file2.cpp(and file2.h)
    and there is also a header file called "header.h"
    which is included in both of the above files.
    namely #include "header.h" is in file1.h and file2.h.if in file2.h,there are also a line like:
    #include  "file1.h"
    then the above macro makes header.h included once
    in file1.h.However header.h could also possible be compiled twice if you 
    don't add #pragma once.
    that is when you compile file1.cpp,and file2.cpp.
     
      

  2.   

    once
    #pragma once
    该指令指定该编译指示驻留的文件将只在一次建立中被编译器包括(打开)一次。该编译指示的一种普通用法如下:
    //header.h
    #pragma once
    //接着是你的C或C++代码
      

  3.   

    zhujianping_es的回答很有说服力!