仅包含一个#include-expression一次包含多个头文件吗? [英] Include multiple header-files at once with only one #include-expression?

查看:120
本文介绍了仅包含一个#include-expression一次包含多个头文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该语法是否有可能一次包含多个标头的表达式,而无需为每个新文件编写"#include"表达式?

Is there any expression possible for the syntax to include multiple headers at once, with no need to write the "#include"-expression for each file new?

例如,

#include <stdio.h>, <stdlib.h>, <curses.h>, <string.h>  /* Dummy-Expression 1. */

OR

#include <stdio.h> <stdlib.h> <curses.h> <string.h>     /* Dummy-Expression 2. */

问题是针对C AND C ++的.

Question is for C AND C++.

推荐答案

否,无法执行此操作.您必须将每个 #include 键入(或复制)到自己的行中,如下所示:

No, there is no way to do this. You have to type out (or copy) each #include to its own line, like this:

#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
#include <string.h>

这适用于C和C ++.

This applies to both C and C++.

其他一些答案讨论了如何创建另一个包含每个头文件的头文件,但是我不打算讨论这样做.一般来说,这是一个坏主意,会导致名称空间污染以及更改该头文件时需要重新编译等问题.

Some of the other answers discuss creating another header file that includes each of these, but I'm not going to discuss doing that. It in general is a bad idea and causes issues like namespace pollution and the need to recompile when you change that header file.

这篇关于仅包含一个#include-expression一次包含多个头文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆