头文件没有包含警卫 [英] header file without include guard

查看:75
本文介绍了头文件没有包含警卫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,全部:

如果头文件具有完全相同的名称但

不同的内容并且声明/定义没有包含保护的头文件驻留在

编译器的包含路径?

这些头文件是否包含多次?如果是这样,是否最后包含的文件总是覆盖前一个文件?这是否可以预测这个

的行为?

谢谢。

Hi, all:
What will happen if header files with the exact same names but with
different contents and declared/defined without include guard reside in
the include path for the compiler?
Are these header files are included more than once? If so, is it the
lastest included file always overwrite the previous one? Is this
behavior predictable?
thanks.

推荐答案

我们***** @ yahoo.com 写道:
如果头文件准确无误将会发生什么相同的名称但具有
不同的内容和声明/定义而不包括保护驻留在编译器的包含路径中?


没什么。他们只是住在那里。

这些头文件是否被包含多次?


包括在内?谁说了什么呢?哦,你问的是你实际上是否写了



#include" thename.ext"


in你的一个文件,会发生什么,对吧?这是特定于编译器的。

如果是这样,最新包含的文件总是会覆盖前一个文件吗?这个
行为是否可以预测?
What will happen if header files with the exact same names but with
different contents and declared/defined without include guard reside in
the include path for the compiler?
Nothing. They just reside there.
Are these header files are included more than once?
Included? Who said anything about including them? Oh, you are asking if
you actually write

#include "thename.ext"

in one of your files, what would happen, right? That''s compiler-specific.
If so, is it the
lastest included file always overwrite the previous one? Is this
behavior predictable?




在同一个编译器中它必须是。请参阅您的编译器

文档。 RTFM,IOW。


V



Within the same compiler it must be. Refer to your compiler
documentation. RTFM, IOW.

V



我们***** @ yahoo.com 写道:
全部:
如果头文件具有完全相同的名称,但会发生什么?
不同的内容和声明/定义没有包括守护驻留在编译器的包含路径中?
这些头文件是否被包含多次?如果是这样,最新包含的文件总是会覆盖前一个文件吗?这个
行为是否可以预测?
谢谢。
Hi, all:
What will happen if header files with the exact same names but with
different contents and declared/defined without include guard reside in
the include path for the compiler?
Are these header files are included more than once? If so, is it the
lastest included file always overwrite the previous one? Is this
behavior predictable?
thanks.



只包含第一个找到的文件。所以它依赖于

编译器,它将首先查找具有该名称的文件。 Usualy,

编译器在INCLUDE

环境变量中指定的目录中查找包含,与指定的顺序完全相同




Only the first found file will be included. So it depends on the
compiler where it will look for a file with that name first. Usualy,
compiler looks for includes in the directories specified in INCLUDE
environment variable, in exact the same order as they are specified
there.


我们***** @ yahoo.com 写道:
全部:
如果头文件具有完全相同的名称但具有不同内容且声明/定义而不包含后卫的头文件将驻留在编译器的包含路径?
这些头文件是否包含多次?如果是这样,最新包含的文件总是会覆盖前一个文件吗?这种行为是否可以预测?
谢谢。
Hi, all:
What will happen if header files with the exact same names but with
different contents and declared/defined without include guard reside in
the include path for the compiler?
Are these header files are included more than once? If so, is it the
lastest included file always overwrite the previous one? Is this
behavior predictable?
thanks.




编译器只会看到第一个头文件,而不是第二个头文件。

它看到的第一个头文件应该是首先列出的路径

在包含路径中。



The compiler will only see the first header file, and not the second.
The first header file it sees should be the path that is listed first
in the include path.


这篇关于头文件没有包含警卫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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