c++ - 警告 : section "__textcoal_nt" is deprecate since updating to Mac OSX Sierra

标签 c++ xcode macos c++11

<分区>

更新到 Sierra 后,我将我的 Xcode 从 7.2.1 更新到 Xcode 8。所以问题可能只是通过更新 Xcode 发生的。我降级回 7.2.1,但仍然遇到同样的问题。

这是我在编译C++程序时遇到的错误

/var/folders/cj/1h3_84h56c9bgzt_ryhpf4940000gn/T//ccgjxtCM.s:4:11: warning: section "__textcoal_nt" is deprecated
        .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                 ^      ~~~~~~~~~~~~~
/var/folders/cj/1h3_84h56c9bgzt_ryhpf4940000gn/T//ccgjxtCM.s:4:11: note: change section name to "__text"
        .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                 ^      ~~~~~~~~~~~~~
/var/folders/cj/1h3_84h56c9bgzt_ryhpf4940000gn/T//ccgjxtCM.s:54:11: warning: section "__textcoal_nt" is deprecated
        .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                 ^      ~~~~~~~~~~~~~
/var/folders/cj/1h3_84h56c9bgzt_ryhpf4940000gn/T//ccgjxtCM.s:54:11: note: change section name to "__text"
        .section __TEXT,__textcoal_nt,coalesced,pure_instructions

程序仍在运行,但会显示此消息。即使代码中唯一的东西是我创建的名为 graph 的类,并且我有这样的代码,也会出现错误。

void explore(Graph & G, int x)
{
  Node* nodePtr = &G.changeNode(x);
}

我尝试在命令行中执行此操作,但没有成功

sudo xcode-select -s /Library/Developer/CommandLineTools

这是我在 Sublime Text 中使用的构建,但即使使用不是 c++11 的其他 c++ 编译器,我也会遇到同样的错误。错误也出现在命令行上。

{
    "shell_cmd": "g++ -std=c++11 \"${file}\" -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",

    "shell_cmd": "g++ -std=c++11 \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}

我认为唯一可行的方法是使用我在该站点上的某些线程上看到的补丁

http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151012/305992.html

我不知道如何使用它们或如何运行。

最佳答案

这里的答案:https://solarianprogrammer.com/2016/09/22/compiling-gcc-6-macos/

您可以安全地忽略所有这些警告,这些警告与 GCC 生成的汇编代码有关,与您的 C++ 代码无关。

不幸的是,目前无法指示 GCC 不使用 __textcoal_nt,或消除上述警告。一个快速而肮脏的解决方法是用类似的东西过滤编译器的输出:

g++-6 main.cpp -o main 2>&1 >/dev/null | grep -v -e '^/var/folders/*' -e '^[[:space:]]*\.section' -e '^[[:space:]]*\^[[:space:]]*~*'

关于c++ - 警告 : section "__textcoal_nt" is deprecate since updating to Mac OSX Sierra,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39865367/

相关文章:

c++ - 带有 const 指针的 vector 构造函数示例

objective-c - 在自动生成的 Swift 桥接 header 中“找不到接口(interface)声明”

ios - 在 Mac 上加载移动网站

ios - Xcode 存档错误 : Missing IOS Distribution Signing Identity For (Name)

macos - 登录私有(private) Docker 注册表时缺少客户端证书错误

cocoa - NSFileManager 错误?

c++ - 未看到包含的头文件

python - 安装 QuantLib Python 时出现问题

c++ - lambda函数可以递归吗?

ios - 调用目录分机-找不到分机