为什么要在项目中使用#include_next? [英] Why would one use #include_next in a project?

查看:45
本文介绍了为什么要在项目中使用#include_next?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

引用 iOS 关于 Wrapper Headers 的文档:

#include_next 不区分 <file>和文件"包含,也不会检查您指定的文件是否相同名称为当前文件.它只是查找名为的文件,开始搜索路径中的目录位于当前目录之后文件已找到.

#include_next does not distinguish between <file> and "file" inclusion, nor does it check that the file you specify has the same name as the current file. It simply looks for the file named, starting with the directory in the search path after the one where the current file was found.

使用 `#include_next' 会导致极大的混乱.我们推荐只有在没有其他选择时才使用它.特别是,它不应在属于特定程序的标头中使用;它应该只用于沿线进行全局更正修复包括.

The use of `#include_next' can lead to great confusion. We recommend it be used only when there is no other alternative. In particular, it should not be used in the headers belonging to a specific program; it should be used only to make global corrections along the lines of fixincludes.

那么,两个问题,什么是#include_next,为什么你需要使用它?

So, two questions, what is #include_next, and why would you ever need to use it?

推荐答案

如果您想用自己制作的一个替换默认标题,例如,假设您想替换stdlib.h",则使用它.您将在项目中创建一个名为 stdlib.h 的文件,该文件将被包含在内,而不是默认标头.

It is used if you want to replace a default header with one of your own making, for example, let's say you want to replace "stdlib.h". You would create a file called stdlib.h in your project, and that would be included instead of the default header.

#include_next 用于向 stdlib.h 添加一些东西而不是完全替换它.您创建一个名为 stdlib.h 的新文件,其中包含:

#include_next is used if you want to add some stuff to stdlib.h rather than replace it entirely. You create a new file called stdlib.h containing:

#include_next "stdlib.h"
int mystdlibfunc();

并且编译器不会再次递归地包含你的 stdlib.h,就像普通的#include 一样,而是继续在其他目录中查找名为stdlib.h"的文件.

And the compiler will not include your stdlib.h again recursively, as would be the case with plain a #include, but rather continue in other directories for a file named "stdlib.h".

这篇关于为什么要在项目中使用#include_next?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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