MacOS Clion 使用<bits/stdc++.h>万能头提示 fatal error: ‘bits/stdc++.h‘ file not found
百度搜了一圈答案,都大坑了,自己亲自塘坑并借鉴了这篇文章之后解决了问题
- 首先进入到下述路径
cd /Library/Developer/CommandLineTools/usr/bin
- 然后进入include路径
cd ../include
- 创建一个bits目录
sudo mkdir bits
- 进入刚刚创建的bits目录下
vim ~/Downloads/stdc++.h
- 编辑刚刚创建的stdc++.h文件, 编辑完之后:wq保存并退出。(这里注意一下,第93行代码的#include <source_location> 这个我本地会提示说找不到这个头文件,因此我将其注释掉了)
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2022 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 stdc++.h
* This is an implementation file for a precompiled header.
*/
// 17.4.1.2 Headers
// C
// C++
//
//
//
// C
// C++
//
- 复制上述编辑好的stdc++.h文件到对应目录下
sudo cp ~/Downloads/stdc++.h /Library/Developer/CommandLineTools/usr/include/bits/stdc++.h
然后就可以在clion中引用万能头文件#include<bits/stdc++.h>头文件了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)