简体   繁体   English

C ++-是否包含所有sys标头?

[英]C++ - Include all sys headers?

I know you can include a specific header file from sys , like #include <sys/stat.h> , but can I include all of the headers from sys ? 我知道您可以包含sys的特定头文件,例如#include <sys/stat.h> ,但是我可以包含sys 所有头吗?

If this is not possible, could someone point me to where this folder is located? 如果无法做到这一点,有人可以指出我该文件夹的位置吗?

You have to include all required headers individually. 您必须单独包括所有必需的标题。 As workaround you can create header file (eg all_sys.h) and put all necessary headers from sys into it. 解决方法是,您可以创建头文件(例如all_sys.h),并将sys所有必要的头放入其中。

Header files location depends on system/compiler. 头文件的位置取决于系统/编译器。 On my system it's located in /usr/include/sys If you are not sure about location you can look at output of macro-processor. 在我的系统上,它位于/usr/include/sys如果不确定位置,可以查看宏处理器的输出。 To get it you should use -E option (linux/gcc), for instance: 要获得它,您应该使用-E选项(linux / gcc),例如:

$ g++ main.cpp -E | less

Notice that if you include redundant headers "just in case" it will increase compilation time unnecessarily 请注意,如果“以防万一”包括多余的头文件,则会不必要地增加编译时间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM