How does #include lt;bits/stdc++.hgt; work in C++?(#include lt;bits/stdc++.hgt;在 C++ 中工作?)
问题描述
我从 codeforces 博客中了解到,如果我们添加 #include <bits/stdc++.h> 在 C++ 程序中,则不需要包含任何其他头文件.#include #include 是如何工作的,是否可以使用它而不是包含单个头文件?
I have read from a codeforces blog that if we add #include <bits/stdc++.h> in a C++ program then there is no need to include any other header files. How does #include <bits/stdc++.h> work and is it ok to use it instead of including individual header files?
推荐答案
它基本上是一个头文件,还包括每个标准库和 STL 包含文件.我能看到它的唯一目的是测试和教育.
It is basically a header file that also includes every standard library and STL include file. The only purpose I can see for it would be for testing and education.
参见例如GCC 4.8.0/bits/stdc++.h 源码一>.
使用它会包含很多不必要的东西并增加编译时间.
Using it would include a lot of unnecessary stuff and increases compilation time.
正如尼尔所说,它是预编译头的实现.如果您正确地将它设置为预编译,它实际上可以根据您的项目加快编译时间.(https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html)
As Neil says, it's an implementation for precompiled headers. If you set it up for precompilation correctly it could, in fact, speed up compilation time depending on your project. (https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html)
但是,我建议您花时间了解每个 sl/stl 标头并单独包含它们,并且除了预编译目的之外不要使用超级标头".
I would, however, suggest that you take time to learn about each of the sl/stl headers and include them separately instead, and not use "super headers" except for precompilation purposes.
这篇关于#include <bits/stdc++.h>在 C++ 中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:#include <bits/stdc++.h>在 C++ 中工作?
基础教程推荐
- CString 到 char* 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
