<bdo id='gL8Cm'></bdo><ul id='gL8Cm'></ul>

    1. <small id='gL8Cm'></small><noframes id='gL8Cm'>

      1. <i id='gL8Cm'><tr id='gL8Cm'><dt id='gL8Cm'><q id='gL8Cm'><span id='gL8Cm'><b id='gL8Cm'><form id='gL8Cm'><ins id='gL8Cm'></ins><ul id='gL8Cm'></ul><sub id='gL8Cm'></sub></form><legend id='gL8Cm'></legend><bdo id='gL8Cm'><pre id='gL8Cm'><center id='gL8Cm'></center></pre></bdo></b><th id='gL8Cm'></th></span></q></dt></tr></i><div id='gL8Cm'><tfoot id='gL8Cm'></tfoot><dl id='gL8Cm'><fieldset id='gL8Cm'></fieldset></dl></div>
        <tfoot id='gL8Cm'></tfoot>
      2. <legend id='gL8Cm'><style id='gL8Cm'><dir id='gL8Cm'><q id='gL8Cm'></q></dir></style></legend>

        如何确定 C++ 编译器的默认 C++ 标准是什么?

        时间:2023-10-17
        <tfoot id='zAlOE'></tfoot>
      3. <i id='zAlOE'><tr id='zAlOE'><dt id='zAlOE'><q id='zAlOE'><span id='zAlOE'><b id='zAlOE'><form id='zAlOE'><ins id='zAlOE'></ins><ul id='zAlOE'></ul><sub id='zAlOE'></sub></form><legend id='zAlOE'></legend><bdo id='zAlOE'><pre id='zAlOE'><center id='zAlOE'></center></pre></bdo></b><th id='zAlOE'></th></span></q></dt></tr></i><div id='zAlOE'><tfoot id='zAlOE'></tfoot><dl id='zAlOE'><fieldset id='zAlOE'></fieldset></dl></div>

        <small id='zAlOE'></small><noframes id='zAlOE'>

          <tbody id='zAlOE'></tbody>

          1. <legend id='zAlOE'><style id='zAlOE'><dir id='zAlOE'><q id='zAlOE'></q></dir></style></legend>

                  <bdo id='zAlOE'></bdo><ul id='zAlOE'></ul>
                • 本文介绍了如何确定 C++ 编译器的默认 C++ 标准是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  经常提到应该使用-std标志来指定编译C++程序时希望使用的标准(例如,-std=c++11-std=gnu++11).通常未解决的相关问题(至少据我所知;例如,请参见 theDennis 在 Oskar N 所选答案下的高度赞成的评论.) 是如何确定编译器使用的默认 C++ 标准是什么.

                  It is frequently mentioned that the -std flag should be used to specify the standard that one wishes to use when compiling a C++ program (e.g., -std=c++11 or -std=gnu++11). A related question that is not typically addressed (at least as far as I can tell; see, for instance, the highly-upvoted comment by Dennis under the selected answer by Oskar N.) is how to determine what the default C++ standard that is being used by the compiler is.

                  我相信可以通过查看手册页(至少对于 g++)来判断,但我想问这是否正确,以及是否有更明确/具体的方法:

                  I believe that it is possible to tell by looking at the man page (at least for g++), but I wanted to ask if this is correct and also if there are more definitive/concrete methods:

                  -std 的描述下,手册页列出了所有 C++ 标准,包括 GNU 方言.在一个特定的标准下,它是相当不起眼的声明,这是C++代码的默认值.(C标准有一个类似的声明:这是C代码的默认值.).

                  Under the description of -std, the man page lists all C++ standards, including the GNU dialects. Under one specific standard, it is rather inconspicuously stated, This is the default for C++ code. (there is an analogous statement for C standards: This is the default for C code.).

                  例如,对于 g++/gcc version 5.4.0,它列在 gnu++98/gnu++03 下,而对于 g++/gcc version 6.4.0,在gnu++14下列出.

                  For instance, for g++/gcc version 5.4.0, this is listed under gnu++98/gnu++03, whereas for g++/gcc version 6.4.0, this is listed under gnu++14.

                  这自然似乎表明默认标准,但它写得所以不显眼,我并不完全确定.如果是这种情况,也许这对那些想知道同样问题的其他人有用.其他C++编译器还有其他方便的方法吗?

                  This would naturally seem to indicate the default standard, but it is written so inconspicuously that I am not entirely certain. If this is the case, perhaps this will be of use to others who have wondered about this very same question. Are there other convenient methods for other C++ compilers?

                  我遇到了这个相关问题,但那里的答案相当复杂,并没有产生具体、明确的陈述.或许我应该在得到证实后提交这个作为该问题的答案.

                  I came across this related question, but the answers there were quite convoluted and did not yield concrete, definitive statements. Perhaps I should submit this as an answer to that question once it has been corroborated.

                  推荐答案

                  如何编译和执行下面的琐碎程序?

                  What about compiling and executing the following trivial program ?

                  #include <iostream>
                  
                  int main()
                   { std::cout << __cplusplus << std::endl; }
                  

                  打印的值应该说明使用的版本:

                  The value printed should say the version used:

                  • 199711 用于 C++98,
                  • 201103 用于 C++11
                  • 201402 用于 C++14
                  • 201703 用于 C++17

                  如果您编译时省略了 -std=c++xx 标志,您应该能够检测到所使用语言的默认版本.

                  If you compile omitting the -std=c++xx flag, you should be able to detect the default version of language used.

                  这篇关于如何确定 C++ 编译器的默认 C++ 标准是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:模板:使用前向声明来减少编译时间? 下一篇:为什么需要为每个操作系统重新编译 C/C++?

                  相关文章

                  <i id='q0pBp'><tr id='q0pBp'><dt id='q0pBp'><q id='q0pBp'><span id='q0pBp'><b id='q0pBp'><form id='q0pBp'><ins id='q0pBp'></ins><ul id='q0pBp'></ul><sub id='q0pBp'></sub></form><legend id='q0pBp'></legend><bdo id='q0pBp'><pre id='q0pBp'><center id='q0pBp'></center></pre></bdo></b><th id='q0pBp'></th></span></q></dt></tr></i><div id='q0pBp'><tfoot id='q0pBp'></tfoot><dl id='q0pBp'><fieldset id='q0pBp'></fieldset></dl></div>

                  1. <tfoot id='q0pBp'></tfoot>
                      <bdo id='q0pBp'></bdo><ul id='q0pBp'></ul>

                    1. <small id='q0pBp'></small><noframes id='q0pBp'>

                      <legend id='q0pBp'><style id='q0pBp'><dir id='q0pBp'><q id='q0pBp'></q></dir></style></legend>