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

alq974120alq 2003-10-31 03:28:12
我看书的时候,看到的这个,不知道是干什么的,哪位指点一下。。
...全文
235 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用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
  • 打赏
  • 举报
回复
书印刷错误.
资源下载链接为: https://pan.quark.cn/s/abbae039bf2a 在计算机科学领域,编译原理是研究如何将编程语言转化为机器可执行代码的理论基础。其,三地址代码(Three-Address Code,TAC)作为一种间表示形式,在编译器设计经常被使用,尤其是在生成目标代码的阶段。本文将深入探讨三地址代码的概念、生成器的工作原理及其在编译过程的作用。 三地址代码是一种简单的低级抽象语法树(AST)表示,每条指令涉及三个操作数,通常包括两个源操作数和一个目的操作数。这种格式简化了代码优化和目标代码生成的复杂性。例如,一个简单的算术表达式“x = y + z”在三地址代码可能表示为: 在这个例子,“t1”是一个临时变量,存储了“y + z”的结果,然后这个结果被赋值给“x”。 生成三地址代码的过程通常发生在编译器的间阶段,即语法分析之后,语义分析之前。这个阶段称为“代码生成”或“间代码生成”。编译器通过词法分析器处理源代码,将其转化为标记流;接着,语法分析器根据上下文无关文法将标记流解析成抽象语法树。三地址代码生成器就是在这个阶段介入,它遍历AST,为每个节点生成对应的三地址指令。 在Turbo C3.0这样的编译器环境下,开发者可以实现自己的三地址代码生成器。虽然Turbo C3.0是一款较老的编译器,但其C语言编译器设计原理依然适用于现代编译器开发。开发过程,我们需要考虑如下关键点: 符号表管理:符号表记录了程序所有标识符的类型、作用域和关联地址,对于生成三地址代码至关重要,因为它提供了关于操作数的类型信息。 数据类型转换:编译器必须处理不同数据类型的运算,确保它们在三地址代码正确表示。例如,整型与浮点型之间的转换需要特别处理。

24,860

社区成员

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

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