更新 OSX 命令行工具 6.3 后缺少C++标头<__debug>

Missing C++ header <__debug> after updating OSX Command Line Tools 6.3

本文关键字:标头 gt lt debug C++ 工具 命令行 OSX 更新      更新时间:2023-10-16

从App Store更新到命令行工具6.3后,包括内部包含<__debug>的<vector><iterator>的程序将导致文件未找到错误,如下所示。cpp 没什么有趣的,但包含在包含的标头之一中。

c++ -O3 -I/Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers -L/Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/build/binaries/clusterStaticLibrary /Users/farleylai/Documents/dev/git/ESMS/Optimizer/build/StreamIt/FIR/511/512/combined_threads.cpp -o streamit -lcluster -lpthread -lstdc++
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/build/StreamIt/FIR/511/512/combined_threads.cpp:9:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/node_server.h:22:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/thread_info.h:20:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/connection_info.h:19:
/Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/socket_holder.h:43:25: warning: delete called on 'mysocket' that is abstract but has non-virtual destructor
      [-Wdelete-non-virtual-dtor]
    if (!is_mem_socket) delete sock;
                        ^
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/build/StreamIt/FIR/511/512/combined_threads.cpp:9:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/node_server.h:22:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/thread_info.h:26:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:265:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__bit_reference:15:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:641:10: fatal error: '__debug' file not found
#include <__debug>
         ^

有什么想法可以解决这个问题吗?我不希望指定任何其他C++标志。

谢谢。

PS:OSX 10.10.3上的MacBook pro

更新:

苹果在其开发者论坛上验证了该问题。在命令行工具 6.2 中,包含 __debug 有条件地保护如下,但在 6.3 中没有。

#ifdef _LIBCPP_DEBUG
#   include <__debug>
#else
#   define _LIBCPP_ASSERT(x, m) ((void)0)
#endif

libcxx人在这里谈论撤掉__debug的守卫。感觉__debug在OSX上永远不会存在。

通过 Apple 的开发者下载页面将命令行工具降级到 6.2

请小心下载适用于您的 OS X 的正确版本:

  • OS X 10.10 commandlinetoolsosx10.10forxcode6.2.dmg
  • OS X 10.9 commandlinetoolsosx10.9forxcode6.2.dmg

这是有效的,因为包含__debug在命令行工具 6.2 中是有条件的,但在 6.3 中不是。

#ifdef _LIBCPP_DEBUG
#   include <__debug>
#else
#   define _LIBCPP_ASSERT(x, m) ((void)0)
#endif

在我看来,这是最安全的方法,因为:

  1. 您不会损害您的工具链
  2. 当Apple解决问题时,您可以通过App Store轻松升级
  3. 如果手动添加文件,则必须稍后将其删除,否则可能会出现更多问题

更新 - 21.04.2015

苹果修复的问题。安装命令行工具 6.3.1 后,一切按预期工作!

临时创建缺少的__debug文件,其中_LIBCPP_ASSERT定义为 OS X 的命令行工具 6.2。

echo '#define _LIBCPP_ASSERT(x, m) ((void)0)' | sudo tee -a /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug > /dev/null

生成完成后删除临时文件。

sudo rm /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug

警告!!这是一个黑客,使用风险自负!!此解决方法仅作为临时修复,直到 Apple 提供命令行工具的更新。

好的,我们开始:自己创建文件并将以下内容放入其中:

#ifndef _LIBCPP_ASSERT
#define _LIBCPP_ASSERT(...) ((void)0)
#endif

似乎对我有用,但这肯定不是正确的做法。 确保文件位于正确的位置,/Library/Developer/CommandLineTools/usr/include/c++/v1/__debug具有正确的所有者/权限。

这现已在命令行工具 6.3.1 中修复,可从 https://developer.apple.com/downloads 获得。 更新应自动显示在您的 App Store 更新中(尽管它标记为 6.3,而不是 6.3.1(。 对于给您带来的不便,我们深表歉意,并非常感谢您报告此问题。

早些时候:在简单的情况下,对我有用的解决方法是设置OS X 10.8或更早版本的最低版本,"-mmacosx-version-min=10.8"。

我遵循了谢里登@Flash建议,让我的CLT再次工作(git,ruby,brew...( - 我使用了"命令行工具(OS X 10.10(用于Xcode 6.3.1"。