顺晟科技
2021-08-28 09:39:00
142
一、介绍通用头文件
头文件bits/stdc包含C的大部分头文件,支持在大部分故障诊断平台和比赛中嵌入头文件,从而减少写头文件的工作量,节省问题时间,让选手们更加专注于算法本身。但是,在编写程序时不建议使用。头文件不是C标准的一部分,因此减少了代码的可移植性。
第二,有问题
使用VScode时,头文件bits/stdc的包含语句下会出现红色波浪线。
三、解决思路
问题的原因:
VScode在头文件的搜索路径中找不到头文件。
解决方法
头文件中的语句只是包含语句的部分文件,因此可以创建头文件并移动到系统的搜索路径下。
四、程序方法1
首先输入可以找到的头文件iostream
#includeiostream
通过此头文件查找头文件目录
选择Iostreamiostream,然后单击鼠标右键转到定义
右键单击左侧的iostream文件,使其显示在文件夹中
如果右边看不到这个文件,就要手动去文件里找
桌面上的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 ff You cart
//this library is distributed in the hope that it will be useful,//but without any warranty;without even the implied warranty of//merchant ability or fitness for a particular purpose . see the//GNU general public license
//under section 7 of GPL version 3,you are granted additional//permissions described in the gcc runtime library exception,ved
//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
/* * @ filestdc . h * this is an implementation file for a precompiled header .*/
//17.4.1.2头
//C
//www.oicqzone.com
#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
将保存的头文件放入以前打开的include目录中(需要管理员权限)
此时返回vscode,您会发现红色下划线消失了
五、结果测试
用hello word测试以下内容
#include bits/stdc。h
Using namespace STD
Int main()
{
Cout ' Hello world \ n
return 0;
}
可以使用头文件!
六、程序方法2
如果安装了Vs2019,但使用mingw,则Vs代码检测默认使用vs2019的msvc编译器的头文件,如果使用mingw特有的特殊头文件,则可能会报告找不到头文件的错误。
将鼠标移动到错误报告头文件时,将显示灯泡。单击并选择编辑“includePath”设置,然后从指定的编译器下拉列表中选择gcc或g
06
2024-03
05
2024-03
04
2024-03
01
2023-08
04
2023-07
23
2023-06