#include_next 中 #include_next 是干什么的>>>>>>>??

alq974120alq 2003-10-31 03:28:12
我看书的时候,看到的这个,不知道是干什么的,哪位指点一下。。
...全文
225 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yisan 2003-11-01
  • 打赏
  • 举报
回复
碰巧前几天也看到了这玩意,查了一下:

[SLL] what's include_next ?
Dwight Johnson Dwight Johnson <dwj@aaronsrod.com>
Thu, 17 Aug 2000 22:44:54 -0700 (PDT)

Previous message: [SLL] what's include_next ?
Next message: [SLL] what's include_next ?
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

--------------------------------------------------------------------------------

On Thu, 17 Aug 2000, Bill Campbell wrote:

> On Thu, Aug 17, 2000 at 08:29:41PM -0700, Brian Denheyer wrote:
> >
> >I have been working on a foreign function generator and it keeps
> >running into a :
> >
> >#include_next
>
> I've run into this, but don't remember where I found the docs (probably in
> the gcc info pages which require that I relearn info every time I try to
> use it).
>
> If I remember correctly, this tells the gcc preprocessor to look for the
> included file name starting in the next directory in the header search
> path.

A Google search gives us more at:

http://www.linuxpowered.com/archive/gnuman/cpp/cpp.html

--
The C Preprocessor
...

Inheritance and Header Files

Inheritance is what happens when one object or file derives some of its
contents by virtual copying from another object or file. In the
case of C header files, inheritance means that one header file includes
another header file and then replaces or adds something.

If the inheriting header file and the base header file have different
names, then inheritance is straightforward: simply write `#include
"base"' in the inheriting file.

Sometimes it is necessary to give the inheriting file the same name as the
base file. This is less straightforward.

For example, suppose an application program uses the system header file
`sys/signal.h', but the version of
`/usr/include/sys/signal.h' on a particular system doesn't do what the
application program expects. It might be convenient to
define a "local" version, perhaps under the name
`/usr/local/include/sys/signal.h', to override or add to the one supplied
by
the system.

You can do this by using the option `-I.' for compilation, and writing a
file `sys/signal.h' that does what the application program
expects. But making this file include the standard `sys/signal.h' is not so
easy--writing `#include <sys/signal.h>' in that file
doesn't work, because it includes your own version of the file, not the
standard system version. Used in that file itself, this leads to an
infinite recursion and a fatal error in compilation.

`#include </usr/include/sys/signal.h>' would find the proper file, but that
is not clean, since it makes an assumption about
where the system header file is found. This is bad for maintenance, since
it means that any change in where the system's header files
are kept requires a change somewhere else.

The clean way to solve this problem is to use `#include_next', which means,
"Include the next file with this name." This command
works like `#include' except in searching for the specified file: it starts
searching the list of header file directories after the directory in
which the current file was found.

Suppose you specify `-I /usr/local/include', and the list of directories to
search also includes `/usr/include'; and suppose
that both directories contain a file named `sys/signal.h'. Ordinary
`#include <sys/signal.h>' finds the file under
`/usr/local/include'. If that file contains `#include_next <sys/signal.h>',
it starts searching after that directory, and finds the
file in `/usr/include'.
--

Dwight
--
Dwight Johnson
dwj@aaronsrod.com

buaaaladdin 2003-10-31
  • 打赏
  • 举报
回复
???从未见过,记得C和C++的关键字里都没有这个。
maximos 2003-10-31
  • 打赏
  • 举报
回复
书印刷错误.

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧