Xcode更新后万能头失效

本文介绍了Xcode更新导致C++万能头文件失效的问题及解决方案。通过运行特定命令找到新的头文件目录,并在新目录下创建并编辑stdc++.h来恢复万能头文件。内容包括创建目录、复制旧头文件内容以及列出的大量C++标准库包含文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Xcode更新后原来的C++万能头失效,提示找不到,但之前创建的头文件明明还在,后来发现是因为Xcode更新后头文件目录改了

输入下面命令找头文件目录

echo | g++ -v -x c++ -E -

返回如下,红框框住的就是新的文件目录
新目录
为方便对比,把旧目录的截图也贴到下边了
旧目录
所以接下来就是到新头文件目录里创建万能头即可

cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
sudo mkdir bits
cd bits
sudo touch stdc++.h
sudo vim stdc++.h

万能头内容

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file bits/stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值