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

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

问题描述

引用iOS Wrapper Headers文档

To quote the iOS Documentation on 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'会导致很大的混淆。我们建议仅在没有其他替代方案时才使用
。特别是,
不应该用在属于特定程序的头文件中;它
应该只用于使
fixincludes行全球更正。

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天全站免登陆