#define p [英] #define p

查看:123
本文介绍了#define p的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#define q p


我必须承认最基本的困惑。事实上,我只使用了#b $ b #define来#redefine。以上是标准的。

如下:


#define UNNAMED_OS_32_LEAN_AND_MEAN


? frank

--------

-1

#define q p

I must admit to a most elementary confusion. I have only ever used
#define to, in point of fact, #redefine . The above is standard. Is
the following:

#define UNNAMED_OS_32_LEAN_AND_MEAN

? frank
--------
-1

推荐答案

Frank Silvermann <在***** @ invalid.net>写道:
Frank Silvermann <in*****@invalid.net> writes:
#define q p

我必须承认最基本的困惑。事实上,我只使用了#define来#redefine。以上是标准的。是
以下内容:
#define UNNAMED_OS_32_LEAN_AND_MEAN
#define q p

I must admit to a most elementary confusion. I have only ever used
#define to, in point of fact, #redefine . The above is standard. Is
the following:

#define UNNAMED_OS_32_LEAN_AND_MEAN




是的。类似对象宏的定义语法(

不带参数)是:


#define identifier replacement-list new -line


替换列表可以为空。如果是,那么任何出现的

标识符都不会被替换。这样的标识符通常与#ifdef一起使用的
。或者#if defined(...)。


顺便说一下,你的

#define qp

isn'什么'通常被称为重新定义。对于已经被定义为宏的东西,重新定义是

#define。只有当替换列表与现有替换列表相同时才允许使用



-

Keith Thompson (The_Other_Keith) ks***@mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。



Yes. The syntax for a definition of an object-like macro (one that
doesn''t take arguments) is:

# define identifier replacement-list new-line

The replacement-list can be empty. If it is, then any occurrence of
the identifier is replaced by nothing. Such an identifier is usually
used with "#ifdef" or "#if defined(...)".

Incidentally, your
#define q p
isn''t what''s normally called a redefinition. A redefinition is a
#define for something that''s already been defined as a macro. It''s
allowed only if the replacement-list is identical to the existing one.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


Keith Thompson写道:
Keith Thompson wrote:
Frank Silvermann< in ***** @ invalid.net>写道:
Frank Silvermann <in*****@invalid.net> writes:
#define q p

我必须承认最基本的困惑。事实上,我只使用了#define来#redefine。以上是标准的。是
以下内容:
#define UNNAMED_OS_32_LEAN_AND_MEAN
#define q p

I must admit to a most elementary confusion. I have only ever used
#define to, in point of fact, #redefine . The above is standard. Is
the following:

#define UNNAMED_OS_32_LEAN_AND_MEAN



是的。定义类似对象的宏(一个不带参数的定义)的语法是:

#define identifier replacement-list new-line

替换列表可以为空。如果是,那么任何出现的标识符都不会被替换。这种标识符通常与#ifdef一起使用。或者#if defined(...)。

顺便说一句,你的#define q p
并不是通常所说的重新定义。对于已经被定义为宏的东西,重新定义是
#define。只有当替换列表与现有替换列表相同时才允许它。



Yes. The syntax for a definition of an object-like macro (one that
doesn''t take arguments) is:

# define identifier replacement-list new-line

The replacement-list can be empty. If it is, then any occurrence of
the identifier is replaced by nothing. Such an identifier is usually
used with "#ifdef" or "#if defined(...)".

Incidentally, your
#define q p
isn''t what''s normally called a redefinition. A redefinition is a
#define for something that''s already been defined as a macro. It''s
allowed only if the replacement-list is identical to the existing one.




让我从不同的角度尝试这个问题:当预处理器

命中第1阶段的源代码,除了决定什么是什么之外它还做什么

#defined?



Let me try the question from a different angle: when the preprocessor
hits the source in stage 1, what does it do besides deciding what is
#defined ?




Keith Thompson写道:

Keith Thompson wrote:
Frank Silvermann< in ***** @ invalid.net>写道:
Frank Silvermann <in*****@invalid.net> writes:
#define q p

我必须承认最基本的困惑。事实上,我只使用了#define来#redefine。以上是标准的。是
以下内容:
#define UNNAMED_OS_32_LEAN_AND_MEAN
#define q p

I must admit to a most elementary confusion. I have only ever used
#define to, in point of fact, #redefine . The above is standard. Is
the following:

#define UNNAMED_OS_32_LEAN_AND_MEAN



是的。定义类似对象的宏(一个不带参数的定义)的语法是:

#define identifier replacement-list new-line

替换列表可以为空。



Yes. The syntax for a definition of an object-like macro (one that
doesn''t take arguments) is:

# define identifier replacement-list new-line

The replacement-list can be empty.




我无法找到标准允许替换列表的位置

空。在这种情况下,标准通常在语法摘要中使用

后缀''opt''来跟随该术语,并且在这种情况下它不会。也不是
我能找到一个空的替换列表是讨论

的类似对象的宏。


我知道你所描述的是我用过的所有C实现如何工作,但是从快速扫描中我看不出标准是如何允许的。

你能解释一下你是如何得出这个的吗?



I can''t find where the Standard allows the replacement-list to be
empty. In such cases, the Standard usually follows the term with a
suffix of ''opt'' in the syntax summary, and it doesn''t in this case. Nor
can I find any mention of an empty replacement-list is the discussion
of object-like macros.

I know that what you describe is how all C implementations I''ve used
work, but from a quick scan I can''t see how the Standard allows it.
Could you explain how you derive this, please.


这篇关于#define p的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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