zoukankan      html  css  js  c++  java
  • pragma message的作用

    转自:http://blog.csdn.net/normallife/article/details/3710838

    pragma message是用来告诉程序员,程序在编译时期的信息。而outputdebugstr则是告诉程序员,程序在运行时期的信息。

    下面就以一个例子来讲解pragma message。

    配合#if/#ifdef/#ifndef设置编译时的提示信息,例如: 

    //test.cpp 
    
    #define UNICODE 
    
    #ifdef UNICODE 
        #pragma message("使用UNICODE字符集") 
    #else 
        #pragma message("使用ANSI字符集") 
    #endif 
    
    int main() 
    { 
        return 0; 
    } 


    使用cl.exe编译时,会根据是否定义了UNICODE,而有不同的提示 
    定义了UNICODE之后,在命令提示符下编译,显示为 

      D:/code>cl test.cpp /c /EHsc /nologo 
      test.cpp 
      使用UNICODE字符集 


    如果不定义UNICODE,则会显示为 

      D:/code>cl test.cpp /c /EHsc /nologo 
      test.cpp 
      使用ANSI字符集 


    IDE模式下编译,则是显示在output窗口;如果在console模式下编译,则显示在console 窗口。这样程序员根据输出信息就知道字符时unicode 还是 ansi的。

  • 相关阅读:
    js(一)
    css (一)
    html
    Spring MVC(四)
    Spring MVC(三)
    Spring MVC(二)
    Spring MVC(一)
    Druid应用
    C3P0使用
    jdbc(二)
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/5628105.html
Copyright © 2011-2022 走看看