当前位置: 首页 > news >正文

mac vscode 设置万能头文件的方法

1.首先找到include所在的文件夹。
clang++ -E -x c++ - -v < /dev/null
通过这条命令,找到如下目录:
/usr/local/include
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks (framework directory)

逐个进去,在第二个里发现了各种头文件。于是在该文件夹下建立子文件夹bits,然后在命令行模式下通过vi 新建一个stdc++.h文件,
将以下内容拷贝进去:


// C++ includes used for precompiling -*- C++ -*-// Copyright (C) 2003-2014 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
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

保存以后,重新打开vscode,输入include<bits/stdc++.h>,可以通过编译了,大功告成!!


task.json:
{"tasks": [{"type": "cppbuild","label": "C/C++: clang++ 生成活动文件","command": "/usr/bin/clang++","args": ["-fcolor-diagnostics","-fansi-escape-codes","-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": "build","detail": "调试器生成的任务。"}],"version": "2.0.0"
}launch.json:
{"version": "0.2.0","configurations": [{"name": "C/C++: clang++ 生成和调试活动文件","type": "cppdbg","request": "launch","program": "${fileDirname}/${fileBasenameNoExtension}","args": [],"stopAtEntry": false,"cwd": "${fileDirname}","environment": [],"externalConsole": true,"MIMode": "lldb","preLaunchTask": "C/C++: clang++ 生成活动文件"},{"name": "(lldb) 启动","type": "cppdbg","request": "launch","program": "输入程序名称,例如 ${workspaceFolder}/a.out","args": [],"stopAtEntry": false,"cwd": "${fileDirname}","environment": [],"externalConsole": false,"MIMode": "lldb"}]
}c_cpp_properties.json:{"configurations": [{"name": "Mac","includePath": ["${workspaceFolder}/**","/usr/local/include","/usr/bin/"],"defines": [],"macFrameworkPath": ["/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"],"cStandard": "c17","cppStandard": "c++17","intelliSenseMode": "macos-clang-x64"}],"version": 4
}
http://www.jsqmd.com/news/257925/

相关文章:

  • 导师严选8个AI论文软件,助你轻松搞定本科毕业论文!
  • 2026年自动化解决方案推荐:聚焦用户口碑与实效验证的对比评价及最终排名 - 十大品牌推荐
  • 导师推荐10个AI论文平台,自考学生轻松搞定毕业论文!
  • 三相并网逆变器电流模型预测MPC控制Matlab仿真模型(设计源文件+万字报告+讲解)(支持资料、图片参考_相关定制)_文章底部可以扫码
  • 2026年自动化厂家推荐:2026年度市场口碑对比评测与最终推荐排名 - 十大品牌推荐
  • 数据迁移验收的防御性实践框架(优化版)
  • 配置中心实时生效机制测试:保障动态更新的核心防线
  • 2026年1月智能AI客服品牌推荐排行榜单:基于多维度动态分析的十强评测与深度对比 - 十大品牌推荐
  • 美自动驾驶出租车竞赛升温,某中心与OpenAI动态
  • 为何要研究直线沿本身的伸缩变换?
  • 2026年1月智能AI客服品牌推荐排行榜单:十款产品深度对比评测分析 - 十大品牌推荐
  • 2026必备!9个AI论文网站,助研究生搞定毕业论文!
  • 2026年1月智能AI客服品牌推荐排行榜:十大品牌深度对比与选购指南 - 十大品牌推荐
  • 汽车MES系统如何处理生产现场图片导入CKEDITOR?
  • Oracle 《数据库 2 天开发人员指南》第1章:2天Oracle数据库开发介绍 - 教程
  • 看台座椅选择哪家靠谱?2026年度看台座椅实力厂商榜单来了! - 极欧测评
  • 互联网医疗怎样实现电子处方截图跨平台转存到C#.NET?
  • 架空输电线路优质(设计源文件+万字报告+讲解)(支持资料、图片参考_相关定制)_文章底部可以扫码
  • 关于具身智能机器人散热设计的综合分析,结合技术现状、头部企业、市场规模及创新方向
  • 宝塔面板搭建教程 | 完整的云服务器部署实践:Ubuntu + 宝塔 + WordPress
  • 机械CAD如何与CKEDITOR实现图纸截图实时同步上传?
  • 2026年1月智能AI客服品牌推荐排行榜单:十款产品深度对比与评测分析 - 十大品牌推荐
  • 基于VUE的电信学院教学巡查平台[VUE]-计算机毕业设计源码+LW文档
  • OpenGL编程详解PDF下载,现代OpenGL教程资源获取
  • 预算不够、时间不够?打工人必看的 AI PPT 免费方案
  • 2026年1月美容仪推荐排行榜单深度对比评测:聚焦无创科技高质价比之选 - 十大品牌推荐
  • 电脑空闲设置优化指南:idle-pc怎么配置省电又流畅
  • (130页PPT)汽车智能制造企业数字化转型SAP解决方案参考(附下载方式)
  • 电脑无法加载驱动怎么解决?教你手动安装正确方法
  • PHP如何实现跨平台大文件上传的示例代码?