MinGW中添加stdc++.h文件(codeblock中可使用)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/while10/article/details/89225148
codeblock添加MinGW

①大家都知道codeblock需要添加编译器,如果没有编译器,codeblock是无法运行的。如果编译器在编译的时候提示无法运行,只需点击下载一个MinGW(建议网盘下载完直接解压,提取码:m9dh)放在C盘根目录下。
②然后设置codeblock按下图顺序点击,最后将编译器目录设置为 C:\MinGW ,即可解决无法编译的问题。
在这里插入图片描述

MinGW中添加 stdc++.h

这个时候大家写代码又会发现有很多人的代码里有 stdc++.h 头文件,但是自己引用这个文件的时候提示却没有这个文件,下面我们自己添加这个文件,这个问价的作用就是将绝大部分我们需要用到的STL库include进这个文件中,这样我们再#include <stdc++.h> 的时候就可以将我们用到的头文件都引用进来了。
①首先创建一个文件命名为 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 <cstdalign>
#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

②然后将这个代码复制到 MinGW 中的include文件中即可,如下图所示。(其他办法安装的或者其他版本的 MinGW 都是相同的办法将 stdc++.h 文件添加到include中,就是路径可能不同,但只需要找到一个文件夹,里面包含大量的 .h 文件就肯定没有错误)
添加stdc++.h的位置截图

猜你喜欢

转载自blog.csdn.net/while10/article/details/89225148