头卫 [英] header guard
问题描述
我对头部防守感到困惑,例如,
#ifndef SALESITEM_H
#define SALESITEM_H
.. ...
#endif
什么是SALEITEM_H ?它是一个变量名称,还是其他什么?我
找不到SALESITEM_H在所有文件中,所以,我不知道在哪里
" SALEITEM_H"来自。
谢谢。
I am confused by the header guard, for example,
#ifndef SALESITEM_H
#define SALESITEM_H
.....
#endif
what is the "SALEITEM_H" ? It is a variable name, or something else? I
could not find "SALESITEM_H" in all the files, so, I don''t know where
"SALEITEM_H" come from.
Thanks.
推荐答案
" asdf" < li ********* @ gmail.comwrote in message
news:11 ********************* *@b28g2000cwb.googlegr oups.com ...
"asdf" <li*********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>我对标题后卫感到困惑,例如,
#ifndef SALESITEM_H
#define SALESITEM_H
....
#endif
什么是SALEITEM_H ?它是一个变量名称,还是其他什么?我
找不到SALESITEM_H在所有文件中,所以,我不知道在哪里
" SALEITEM_H"来自。
谢谢。
>I am confused by the header guard, for example,
#ifndef SALESITEM_H
#define SALESITEM_H
....
#endif
what is the "SALEITEM_H" ? It is a variable name, or something else? I
could not find "SALESITEM_H" in all the files, so, I don''t know where
"SALEITEM_H" come from.
Thanks.
这是你想要的任何东西,应该是unqiue,但通常它是头文件名的
。对于SALESITEMS_H我会假设标题
文件名是
SalesItems.h
这几乎是一条不成文的规则在_H
结尾的所有大写字母中的变量都用于标题保护。
所以如果你做了一个名为
的头文件
AsdfTools.h
你会成为头球后卫
#ifndef ASDFTOOLS_H
#define ASDFTOOLS_H >
// ...
#endif
It is anything you want it to be and should be unqiue, but generally it''s
the name of the header file. For SALESITEMS_H I would presume the header
file name was
SalesItems.h
It''s pretty much an unwritten rule that variables in all caps ending in _H
are used for header guards.
So if you made a header file called
AsdfTools.h
you would make the header guard
#ifndef ASDFTOOLS_H
#define ASDFTOOLS_H
//...
#endif
asdf写道:
asdf wrote:
我对头部防守感到困惑,例如,
#ifndef SALESITEM_H
#define SALESITEM_H
。 ...
#endif
什么是SALEITEM_H ?它是一个变量名称,还是其他什么?
I am confused by the header guard, for example,
#ifndef SALESITEM_H
#define SALESITEM_H
....
#endif
what is the "SALEITEM_H" ? It is a variable name, or something else?
这是宏的名称。
It''s the name of a macro.
我找不到SALESITEM_H在所有文件中,所以,我不知道在哪里
" SALEITEM_H"来自。
I could not find "SALESITEM_H" in all the files, so, I don''t know where
"SALEITEM_H" come from.
它来自你引用的行。
It comes from just the lines that you quoted.
谢谢。
您能否详细解释一下
标题后卫的目标(或优势)?
Jim Langston写道:
Thanks.
Could you please explain more about the aim (or the advantage) of the
header guard in your example ?
Jim Langston wrote:
所以如果你做了一个名为
的头文件
AsdfTools.h
你会做头部防护罩
#ifndef ASDFTOOLS_H
#define ASDFTOOLS_H
// ...
#endif
So if you made a header file called
AsdfTools.h
you would make the header guard
#ifndef ASDFTOOLS_H
#define ASDFTOOLS_H
//...
#endif
这篇关于头卫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!