使用VS2017遇到的一些小问题

一、去掉预编译头

使用VS2017的时候,发现总是会有“pch.h”,“stdafx.h”这类预编译头,去掉还会报错。作为新手的我,暂时用不到这些预编译头,于是想去掉它们。

右键项目->属性->C/C++->预编译头,如下图所示,然后选择不使用预编译头即可。

1139527-20190501233354179-1636744839.png

二、设置C++标准

用VS2017写C++的时候想设置一下C++标准,设置成C++14或C++17。

右键项目->属性->C/C++->语言,如下图所示,在C++语言标准选择想要的C++版本即可。

1139527-20190501233442421-1657958191.png

三、使用<bits/stdc++.h>头文件

因为直前用别的编译器都习惯用#include<bits/stdc++.h>都懒得打头文件了。然后,发现VS2017使用这个头文件会报错提示找不到,于是上网找了一下办法。

既然VS2017没有,我们就自己加上去,找到VS2017安装目录,然后找到include文件,我的文件路径是这个:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include

然后自己创一个bits文件夹,然后进入bits文件夹,创建stdc++.h文件,添加下面的内容:

// 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

1139527-20190501233503187-1578048502.png

1139527-20190501233518654-1232744878.png

添加完成之后,我们就能正常地使用#include<bits/stdc++.h>了。

转载于:https://www.cnblogs.com/fu3638/p/10801251.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
预编译文件今天在改一个很大的程序,慢慢看,慢慢改。突然发现一个.c文件,里面什么也没有,就几个文件,我一看,我靠,这不是把简单的问题搞复杂了吗,随手删掉那个c文件。结果不能编译了,我靠:fatal error C1083: Cannot open precompiled header file: \'Debug/v13_3.pch\':No such file or directory怎么rebuild all都不行。上网查了一下,才搞懂了:----------------总结------如果工程很大,文件很多,而有几个文件又是经常要用的,那么1。把这些文件全部写到一个文件里面去,比如写到preh.h2。写一个preh.c,里面只一句话:#include "preh.h"3。对于preh.c,在project setting里面设置creat precompiled headers,对于其他.c文件,设置use precompiled header file//哈哈我试了一下,效果很明显,不用precompiled header,编译一次我可以去上个厕所,用precompiled header,编译的时候,我可以站起来伸个懒腰,活动活动就差不多啦---------转载的文章----------预编译的概念:所谓的预编译就是把一个工程中的那一部分代码,预先编译好放在一个文件里(通常是以.pch为扩展名的),这个文件就称为预编译文件这些预先编译好的代码可以是任何的C/C++代码--------甚至是inline的函数,但是必须是稳定的,在工程开发的过程中不会被经常改变。如果这些代码被修改,则需要重新编译生成预编译文件。注意生成预编译文件是很耗时间的。同时你得注意预编译文件通常很大,通常有6-7M大。注意及时清理那些没有用的预编译文件。也许你会问:现在的编译器都有Time stamp的功能,编译器在编译整个工程的时候,它只会编译那些经过修改的文件,而不会去编译那些从上次编译过,到现在没有被修改过的文件。那么为什么还要预编译文件呢?答案在这里,我们知道编译器是以文件为单位编译的,一个文件经过修改后,会重新编译整个文件,当然在这个文件里包含的所有文件中的东西(.eg Macro, Preprocesser )都要重新处理一遍。VC的预编译文件保存的正是这部分信息。以避免每次都要重新处理这些文件。预编译的作用:根据上文介绍,预编译文件的作用当然就是提高便宜速度了,有了它你没有必要每次都编译那些不需要经常改变的代码。编译性能当然就提高了。预编译使用:要使用预编译,我们必须指定一个文件,这个文件包含我们不会经常改变的代码和其他的文件,然后我们用这个文件来生成一个预编译文件(.pch文件)想必大家都知道 StdAfx.h这个文件。很多人都认为这是VC提供的一个“系统级别”的,编译器带的一个文件。其实不是的,这个文件可以是任何名字的。我们来考察一个典型的由AppWizard生成的MFC Dialog Based 程序的预编译文件。(因为AppWizard会为我们指定好如何使用预编译文件,默认的是StdAfx.h,这是VC起的名字)。我们会发现这个文件里包含了以下的文件:#include // MFC core and standard components#include // MFC extensions#include // MFC Automation classes#include // MFC support for Internet Explorer 4Common Controls#include <br
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值