代码之家  ›  专栏  ›  技术社区  ›  Dmitry Romanov

Is#错误指令跨平台和跨编译器

  •  2
  • Dmitry Romanov  · 技术社区  · 9 年前

    我知道 #error GCC MSVC

     #if !defined(__cplusplus)  
     #error C++ compiler required.  
     #endif
    

    但它通常是跨平台和跨编译器的吗?这可能是某种标准的一部分吗?

    注:因为即使看GCC和MSVC手册中给出的示例,也会发现不同之处。尽管它可以同时使用引号或不使用引号,但它可能在某种程度上依赖于编译器,这让人感到悲哀。

    GCC示例

    #error "Won't work on ..."   // quotes here
    

    MSVC示例

    #error C++ compiler required.    // no qutes
    
    1 回复  |  直到 9 年前
        1
  •  7
  •   Bathsheba    9 年前