gpt4 book ai didi

c++ - 如何升级到 C++17?

转载 作者:行者123 更新时间:2023-12-01 14:37:11 32 4
gpt4 key购买 nike

我使用 Atom 作为我的 IDE,我当前的 __cplusplus = 201402这是 C++14,我的编译器是 g++ (GCC) 9.2.0。
如何升级到 C++17 或 C++20?
我搜索的所有内容都涉及使用另一个 IDE(Microsoft Visual Studio)。

最佳答案

您不会“升级”到较新的 C++ 标准。
您可以将编译器升级到支持最新标准的较新版本。
截至今天,大多数编译器默认设置为 C++14。
要更改它,您需要在编译期间传递额外的参数。
例如,编译 hello.cpp使用 GCC for C++17 你需要执行

g++ -std=c++17 hello.cpp
您需要检查如何在 IDE/编辑器/构建系统中传递编译器标志(或设置标准)。

我不熟悉 Atom,但我找到了 this :

In the settings, click on Packages, then search for gpp-compiler. You should see a settings button – click on it and edit the command line options to suit your needs.

关于c++ - 如何升级到 C++17?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63007678/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com