macOS使用C/C++万能头文件保姆级教程

Windows上面用万能头文件为我们省去了不少记头文件的麻烦,切换到macOS上来发现C/C++环境中没有自带这个头文件。不行,今天无论如何都要用到万能头文件。

第一步:安装C/C++环境(本教程使用Xcode软件自带C/C++环境)

方法1:打开App Store,下载Xcode

方法2:进入苹果开发者网站下载Command Line Tool(还是下稳定版好一些)

第二步:打开“终端”,输入

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

找到如下显示内容

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include

第三步:在访达中按“⇧⌘G”来调出“前往文件夹”,输入

Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1

看到这么多熟悉的面孔,相信大家已经知道下一步该干嘛了

第四步:新建文件夹,命名为“bits”,进入“bits”,创建TXT文件并修改名称为“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

第六步:测试

参考:

1.如何快速在macOS上配置VSCode编程Cpp的环境

2.macOS下使用bits/stdc++.h万能头文件

macOS使用C/C++万能头文件保姆级教程相关推荐

  1. 万能头文件#include<bits/stdc++.h>更新GCC10.2.0版本

    C++标准库里的万能头文件:#include<bits/stdc++.h> 可用于各大Online Judge测试平台(POJ除外,这些年不维护更新了) 由于网上的都是2014年版的万能头 ...

  2. c++万能头文件_初学Python,与C对比

    ✎背景学了一学年的C的基础,下学年开课Python,现在正在自学中...C也不是不学了,而是之前买了一本<C++Primer>在学校里,就准备先学一下Python,下学期利用自由时间接着学 ...

  3. VScode找不到C++万能头文件<bits/stdc++.h>解决办法

    VScode找不到C++万能头文件<bits/stdc++.h>解决办法 一.万能头文件介绍 万能头文件<bits/stdc++> 中包含了 C++中大部分头文件,在大部分做题 ...

  4. MAC OS下设置bits/stdc++.h万能头文件

    在MAC下用atom写c++程序时用到万能头文件会比较方便. 准备: 下载xcode或者command line developer tools 地址:https://developer.apple. ...

  5. Visual Studio 中使用万能头文件 #include bits/stdc++.h

    进行各种练习赛后,看题解代码时经常会看到这么一个陌生的头文件 #include <bits/stdc++.h> ,这个头文件是一个C++万能头文件,里面包含了程序比赛中所有可能用到的头文件 ...

  6. Visual Studio 中使用万能头文件 #include <bits/stdc++.h>

    Visual Studio 中使用万能头文件 #include 前言 最近开始使用VS,之前用的DEV C++软件可直接使用 #include <bits/stdc++.h> ,但VS中并 ...

  7. VScode添加C++万能头文件

    VScode添加C++万能头文件 参考:vscode编译器添加c++万能头文件 使用xcode以及vscode时需要自行添加万能头才可以在代码中使用. 本质都是找到软件中储存库函数的文件夹中再添加一个 ...

  8. 【C++】万能头文件 <bits/stdc++.h> 的用法和优缺点

    [C++]万能头文件 bits/stdc++.h 的用法和优缺点 文章目录 [C++]万能头文件 bits/stdc++.h 的用法和优缺点 一.使用方法 二.头文件的内容 三.VS 中如何使用 四. ...

  9. C++万能头文件(bits/stdc++.h)

    先说一句 C++万能头文件,并不是所有场合都能用,比如说POJ. 我曾在POJ提交过程序,编译错误.就是因为用了万能头文件. 意思就是,不认识<bits/stdc++.h>. 因为,万能头 ...

最新文章

  1. Spring Cloud(十)高可用的分布式配置中心 Spring Cloud Config 中使用 Refresh
  2. 图论-欧拉路(UVA10054)(HDU1116)
  3. php.ini文件找不到
  4. js中表单验证常用到的正则表达式
  5. ASP.NET Core 中文文档 第三章 原理(13)管理应用程序状态
  6. qdu_ACM3月7号组队训练
  7. PHP被浏览器解释成注释,HTML+CSS入门 在HTML中嵌入的php代码会被浏览器注释掉如何解决...
  8. vSphere vsan 6.5部署之一VCSA6.5安装
  9. 电子名片+在线商城=?现在居然可以用名片卖货了
  10. GitLab+Git(Git Flow分支模型)
  11. 09-实战拓展(ico图标、图标字体、网站优化三大标签、logo优化、过渡transition、:focus获取元素焦点)
  12. MFC禁用编辑框输入法
  13. 使用RecyclerView自定义实现二级联动列表
  14. SAP MM 采购申请后台配置
  15. python做马尔科夫模型预测法_李航《统计学习方法》第十章——用Python实现隐马尔科夫模型...
  16. 仿滴滴出行页面Demo
  17. 使用QCustomPlot,跟随鼠标动态显示线上点的值
  18. 可以测试体育跑步的软件,某高校现跑步打卡神器 能检测出是在走还是跑
  19. 如何远程访问/控制Mac机
  20. 计算机英语大作业,英语学期大作业

热门文章

  1. php connection reset,connection reset by peer问题总结及解决方案
  2. 智慧时代 你想要的物联网生活
  3. 1119 Pre- and Post-order Traversals (PAT甲级)
  4. 一篇文章读懂什么是CAP(基础入门)
  5. 魅族16php7.3系统,魅族16X 官方Flyme7.3.0.0A稳定版
  6. FPGA | Xilinx ISE14.7 LVDS应用
  7. 浅谈手机app的推广
  8. 火狐浏览器中历史记录、表签丢失后如何找回
  9. AIDE-Libgdx导入Box2d
  10. Java实现论文查重系统