Home  >  Q&A  >  body text

怎样声明 c++代码的版本

perl中可以声明 use 5.010申明代码必须由5.10以上的解析器解析
c++中有没有类似的声明语句声明代码必须由c++11以上的编译器编译,而不是提示语法错误

巴扎黑巴扎黑2715 days ago624

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-04-17 13:28:24

    __cplusplus is a predefined macro

    The value for c++14 is 201402L

    The value for c++11 is 201103L

    The value for c++98 is 199711L

    You can write like this

    #if __cplusplus < 201103L
    #    error "请使用c++11进行编译"
    #endif

    reply
    0
  • Cancelreply