经常在vc中看到pragma,就是不大明白什么意思,比如#pragma once什么什么的?

解决方案 »

  1.   

    Each implementation of C and C++ supports some features unique to its host machine or operating system. Some programs, for instance, need to exercise precise control over the memory areas where data is placed or to control the way certain functions receive parameters. The #pragma directives offer a way for each compiler to offer machine- and operating-system-specific features while retaining overall compatibility with the C and C++ languages. Pragmas are machine- or operating-system-specific by definition, and are usually different for every compiler.引自MSDN
      

  2.   

    http://www.csdn.net/develop/article/19/19337.shtm
    你看看吧
      

  3.   

    #ifndef xxxx
    #define xxxx
    ......
    #endif
    只能保证头文件中的定义不被重复,但不能保证文件不被重复编译(多次打开同一个文件),#pragma once 就是为了防止这种情况的。