警告:自更新到 Mac OSX Sierra 以来,第 "__textcoal_nt" 节已弃用

warning: section "__textcoal_nt" is deprecate since updating to Mac OSX Sierra

本文关键字:textcoal nt 更新 Mac 以来 Sierra OSX 警告      更新时间:2023-10-16

更新到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++编译器,也不是c++11,我得到同样的错误。命令行也出现错误

{
    "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:]]*~*'