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

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

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

        如何在 Mac 终端中使用 C++11 支持编译 C++

        How to compile C++ with C++11 support in Mac Terminal(如何在 Mac 终端中使用 C++11 支持编译 C++)
            <bdo id='B70Eq'></bdo><ul id='B70Eq'></ul>
            • <legend id='B70Eq'><style id='B70Eq'><dir id='B70Eq'><q id='B70Eq'></q></dir></style></legend>
            • <small id='B70Eq'></small><noframes id='B70Eq'>

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

                  本文介绍了如何在 Mac 终端中使用 C++11 支持编译 C++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想在 Mac 终端中编译 C++11 源代码但失败了.我尝试了 g++ -std=c++11g++ -std=c++0xg++ -std=gnu++11g++ -std=gnu++0x 但没有任何效果.终端总是读取无法识别的命令行选项.但是,g++ -std=gnu 之类的东西运行良好(当然 C++11 源代码无法通过).

                  I wanted to compile C++11 source code within Mac Terminal but failed. I tried g++ -std=c++11, g++ -std=c++0x, g++ -std=gnu++11 and g++ -std=gnu++0x but nothing worked. Terminal always read unrecognized command line option. However, g++ -std=gnu and things like that worked fine (of course C++11 source code could not pass).

                  我应该使用哪个选项来开启 C++11 支持?

                  Which option should I use to turn on C++11 support?

                  顺便说一下,我使用的命令行工具安装在 Xcode 中,我很确定它们是最新的.

                  By the way, the command line tool I'm using is installed within Xcode, and I'm pretty sure that they are up-to-date.

                  推荐答案

                  正如其他人所指出的,您应该使用 clang++ 而不是 g++.此外,您应该使用 libc++ 库而不是默认的 libstdc++;包含的 libstdc++ 版本很旧,因此不包含 C++11 库功能.

                  As others have pointed out you should use clang++ rather than g++. Also, you should use the libc++ library instead of the default libstdc++; The included version of libstdc++ is quite old and therefore does not include C++11 library features.

                  clang++ -std=c++11 -stdlib=libc++ -Weverything main.cpp
                  

                  如果您还没有为 Xcode 安装命令行工具,您可以使用 xcrun 工具运行编译器和其他工具,而无需这样做.

                  If you haven't installed the command line tools for Xcode you can run the compiler and other tools without doing that by using the xcrun tool.

                  xcrun clang++ -std=c++11 -stdlib=libc++ -Weverything main.cpp
                  

                  此外,如果您想禁用某个特定警告,您可以将其他标志传递给编译器来执行此操作.在警告消息的末尾,它会向您显示将启用警告的最具体的标志.要禁用该警告,请在警告名称前加上 no-.

                  Also if there's a particular warning you want to disable you can pass additional flags to the compiler to do so. At the end of the warning messages it shows you the most specific flag that would enable the warning. To disable that warning you prepend no- to the warning name.

                  例如,您可能不想要 c++98 兼容性警告.在这些警告结束时,它会显示标志 -Wc++98-compat 并禁用它们,您可以通过 -Wno-c++98-compat.

                  For example you probably don't want the c++98 compatibility warnings. At the end of those warnings it shows the flag -Wc++98-compat and to disable them you pass -Wno-c++98-compat.

                  这篇关于如何在 Mac 终端中使用 C++11 支持编译 C++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                  How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                  Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                  Delay Loading DLLs(延迟加载 DLL)
                  Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                  Loading a dll from a dll?(从 dll 加载 dll?)

                  <legend id='NqNIM'><style id='NqNIM'><dir id='NqNIM'><q id='NqNIM'></q></dir></style></legend>
                  <tfoot id='NqNIM'></tfoot>
                    <bdo id='NqNIM'></bdo><ul id='NqNIM'></ul>

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

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