简体   繁体   English

Eclipse CDT项目中默认的C ++标准是什么?

[英]What is the default C++ standard in an Eclipse CDT project?

I am using Eclipse CDT 3.8.1 with GCC Cross Compiler 8.6.0. 我正在将Eclipse CDT 3.8.1和GCC Cross Compiler 8.6.0一起使用。 I know how to change the C++ standard in the project properties, but I don't know what standard is used by default. 我知道如何在项目属性中更改C ++标准,但是我不知道默认情况下使用什么标准。

I know the default is not C++11 and the Eclipse language support page doesn't mention C++03, so I suspect the default is C++98. 我知道默认的不是C ++ 11,并且Eclipse语言支持页面没有提到C ++ 03,所以我怀疑默认的是C ++ 98。 However, Eclipse CDT must support C++03 because adding the compiler flag -std=c++03 doesn't cause any errors. 但是,Eclipse CDT必须支持C ++ 03,因为添加编译器标志-std = c ++ 03不会引起任何错误。 https://www.eclipse.org/community/eclipse_newsletter/2017/april/article3.php https://www.eclipse.org/community/eclipse_newsletter/2017/april/article3.php

What is the default standard when I create a new project? 创建新项目时的默认标准是什么?

Eclipse's parser itself doesn't have a notion of a C++ standard mode. Eclipse的解析器本身没有C ++标准模式的概念。 It will recognize all the C++ features that have been implemented in its parser (which, as of writing this, is all C++98 and C++11 features, some (but not all) C++14 features, and a handful of C++17 features). 它将识别解析器中已实现的所有C ++功能(在撰写本文时,它是所有C ++ 98和C ++ 11功能,一些(但不是全部)C ++ 14功能以及少数几个C ++ 17功能)。

However, standard library headers often contain sections that are conditional on macros denoting the C++ standard version (eg #if __cplusplus >= 201103 is a common check for "C++11 or later"). 但是,标准库头文件通常包含以表示C ++标准版本的宏为条件的部分(例如, #if __cplusplus >= 201103是对“ C ++ 11或更高版本”的常见检查)。 To determine the value of these macros, Eclipse invokes the compiler specified in the project's toolchain to discover built-in macros. 为了确定这些宏的值,Eclipse调用项目工具链中指定的编译器来发现内置宏。 The discovered value of eg the __cplusplus macro will depend on what standards mode the compiler runs in for this invocation. 例如__cplusplus宏的发现值将取决于编译器为此调用运行的标准模式。

The flags to this compiler invocation are specified in the project properties, as you mentioned. 如前所述,此编译器调用的标志在项目属性中指定。 If you don't provide a flag there, the compiler will use whatever its default mode is. 如果您在此处未提供标志,则编译器将使用其默认模式。 I believe GCC has been using -std=c++14 as the default from GCC 6 onwards. 我相信GCC从GCC 6开始就一直使用-std=c++14作为默认值。 (Though I don't quite know what "GCC Cross Compiler 8.6.0" is. According to the GCC website , the latest version is 8.1.) (尽管我不太清楚“ GCC交叉编译器8.6.0”是什么。根据GCC网站 ,最新版本是8.1。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM