#define的价值是什么? [英] what will be the value of #define
问题描述
你好
我怀疑plz澄清说明
#ifndef SYSTEM_H
#define SYSTEM_H
什么这个#define语句之后将是SYATEM_H的值,并且在该语句之前是
。
感谢大家
再见
Hello
I have a doubt plz clarify that
#ifndef SYSTEM_H
#define SYSTEM_H
what will be the value of SYATEM_H after this #define statement and
before that statement.
Thanking you all
Bye
推荐答案
raghu说:
raghu said:
Hello
我怀疑plz澄清
#ifndef SYSTEM_H
#define SYSTEM_H
SYATEM_H后的价值是多少在该声明之前,这个#define语句和
。
Hello
I have a doubt plz clarify that
#ifndef SYSTEM_H
#define SYSTEM_H
what will be the value of SYATEM_H after this #define statement and
before that statement.
你的#define不会影响SYATEM_H名称的任何标识符 -
但是,假设你的意思是SYSTEM_H,它的值是先前的到#ifndef
取决于它是否存在。如果它没有,那么它的价值在
#define(在你的例子中)将是0.
-
Richard Heathfield
Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk
电子邮件:rjh在上述域名, - www。
Your #define doesn''t affect any identifier by the name of SYATEM_H -
but, presuming you meant SYSTEM_H, its value prior to the #ifndef
depends on whether it exists. If it didn''t, then its value after the
#define (in your example) will be 0.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
raghu写道:
raghu wrote:
你好
我怀疑plz澄清
#ifndef SYSTEM_H
#define SYSTEM_H
在此#define语句之后SYATEM_H的值是什么,在该语句之前是
。
Hello
I have a doubt plz clarify that
#ifndef SYSTEM_H
#define SYSTEM_H
what will be the value of SYATEM_H after this #define statement and
before that statement.
(万一这是一个技巧问题):根据所提供的信息,不可能告诉你,
。
(假设它只是一个错字):在#define之前,SYSTEM_H
没有定义,根本就没有价值。之后,SYSTEM_H被定义为一个类似对象的宏,其替换列表是空的。
-
Eric Sosman
es*****@acm-dot-org.inva 盖子
3月2日13:22,Eric Sosman< esos ... @ acm-dot-org.invalidwrote:
On 2 Mar, 13:22, Eric Sosman <esos...@acm-dot-org.invalidwrote:
raghu写道:
raghu wrote:
你好
我怀疑plz澄清
#ifndef SYSTEM_H
#define SYSTEM_H
在此#define语句之后SYATEM_H的值是什么,在该语句之前是
。
Hello
I have a doubt plz clarify that
#ifndef SYSTEM_H
#define SYSTEM_H
what will be the value of SYATEM_H after this #define statement and
before that statement.
(万一这是一个技巧问题):根据所提供的信息,不可能告诉你,
。
(假设它只是一个错字):在#define之前,SYSTEM_H
没有定义,根本就没有价值。之后,SYSTEM_H被定义为一个类似于对象的宏,其替换列表为空。
(Just in case it''s a trick question): Impossible to tell,
based on the information provided.
(Assuming it''s just a typo): Before the #define, SYSTEM_H
is not defined and has no value at all. After it, SYSTEM_H is
defined as an object-like macro whose replacement list is empty.
为raghu解释一点 - 该方法是一种标准的
约定,用于确保头文件的多个包含物(通常由于嵌套在其他头文件中)是无害的。 />
如果我的标题叫做fred.h形式如下: -
#ifndef FRED_H
#define FRED_H
....
#endif / * FRED_H * /
然后第一个包含将具有宏FRED_H undefined,将
定义宏(作为空宏)并执行其他声明,
定义等标题定义。
任何后续包含将具有FRED_H。定义,所以会做什么
什么都没有。
To explain a little more for "raghu" - the approach is a standard
convention for ensuring that multiple inclusions of header files
(usually due to being nested in other header files) are "harmless".
If my header called "fred.h" has the form:-
#ifndef FRED_H
#define FRED_H
....
#endif /*FRED_H*/
then the first inclusion will have the macro "FRED_H" undefined, will
define the macro (as an empty macro) and do the other declarations,
definitions etc which the header defines.
Any subsequent inclusions will have "FRED_H" defined, so will do
nothing.
这篇关于#define的价值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!