美文网首页
gnu++17和c++17的区别

gnu++17和c++17的区别

作者: dnsir | 来源:发表于2018-11-28 22:15 被阅读17次

1 引言

seastar的编译环境检测有这么一段代码:

if args.cpp_dialect == '':
    cpp_dialects = ['gnu++17', 'gnu++1z', 'gnu++14', 'gnu++1y']
    try:
        args.cpp_dialect = [x for x in cpp_dialects if dialect_supported(x, compiler=args.cxx)][0]
    except:
        # if g++ is not available, fallback to something safe-ish
        args.cpp_dialect='gnu++1y'

这段代码是检测系统编译器支持的C++标准,那么问题来了,gnu++17和c++17有什么区别呢?实际编译时是有如下两种写法:

$ g++-7 const4.cpp --std=gnu++17
$ g++-7 const4.cpp --std=c++17

区别

-std=c++11,支持C++11标准;
-std=gnu++11,支持C++11标准和GNU扩展特性;

那么gnu扩展特性有哪些?可以参考GNU extensions to the C and C++ languages,另外就是C Dialect支持哪些Options Controlling C Dialect,可以参考网页:C-Dialect-Options,另外发现The following options control the dialect of C (or languages derived from C, such as C++, Objective-C and Objective-C++) that the compiler accepts这句话的意思就是该网页上的选项c/c++/object-c/object-c++都是支持的。

总结

多看看Using the GNU Compiler Collection (GCC)才能算是全面掌握C/C++语言。

相关文章

网友评论

      本文标题:gnu++17和c++17的区别

      本文链接:https://www.haomeiwen.com/subject/jartcqtx.html