这在C中是什么? [英] What's this in C?

查看:67
本文介绍了这在C中是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

静态无效(DEVICE_REQUEST)(无效);


此行在C中声明什么?

我总是遇到这样的代码,但是我之前从未学过



它看起来像是函数的声明,但是为什么DEVICE_REQUEST必须引用()引用


任何人都可以向我解释一下吗?非常感谢!

解决方案

zh ********* @ gmail.com 写道:

static void(DEVICE_REQUEST)(void);

这是什么行声明在C?
我总是遇到这样的代码,但我以前从未学过
它看起来像是函数的声明,但为什么DEVICE_REQUEST必须任何人都可以向我解释这个问题?非常感谢!




好​​吧,如果你展示DEVICE_REQUEST是什么,它会有很大的帮助。


一个原因吧可能在括号中,如果它的#defined为:


#define DEVICE_REQUEST * some_name


然后请确保您的原始行将`some_name`声明为

指向函数的指针,该函数不带参数并返回void

(无):


static void(* some_name)(void);


它不是一个函数的声明,而是一个可以用来调用函数的指针。

调用一个函数。 br />

这是您正在寻找的答案吗?如果没有,请告诉我们

DEVICE_REQUEST是什么。


-

BR,Vladimir


zh ********* @ gmail.com 写道:

static void(DEVICE_REQUEST)(void);

这一行在C中声明了什么?
我总是遇到这样的代码,但我之前从未学过
它看起来像是函数的声明,但为什么DEVICE_REQUEST必须由()引用。




是的。括号是可选的,但是如果定义了一个名为

DEVICE_REQUEST的函数式宏,则括号会阻止宏替换。


-

Thad


zh ******* **@gmail.com 说:

static void(DEVICE_REQUEST)(void);

这一行在C中声明了什么?


一个名为DEVICE_REQUEST的函数,它不带任何参数并且不返回

值,并且具有内部链接。

我是总是遇到这样的代码,但我以前从未学过

它看起来像是函数的声明,但为什么DEVICE_REQUEST必须被()引用。



如果某个小丑已经完成了


#define DEVICE_REQUEST(x)someexpressioninvolving x


括号使预处理器停止执行通常的

替换。定义和调用必须类似

括号:


void(DEVICE_REQUEST)(无效)

{

;

}


int main(无效)

{

( DEVICE_REQUEST)();

返回0;

}


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)


static void (DEVICE_REQUEST)(void);

What does this line declare in C?
I am always meeting some codes like this,but I have never learnt that
before.
It looks like a declaration of a function,but why DEVICE_REQUEST has to
be quoted by ( ).
Anyone can explain that to me? thanks a lot!

解决方案

zh*********@gmail.com wrote:

static void (DEVICE_REQUEST)(void);

What does this line declare in C?
I am always meeting some codes like this,but I have never learnt that
before.
It looks like a declaration of a function,but why DEVICE_REQUEST has to
be quoted by ( ).
Anyone can explain that to me? thanks a lot!



Well, it would have helped a lot if you showed what DEVICE_REQUEST is.

One reason it might be in parentheses is if it''s #defined as:

#define DEVICE_REQUEST *some_name

Parenthese then make sure your original line declares `some_name` as a
pointer to a function which takes no parameters and returns void
(nothing):

static void (*some_name)(void);

It is not a declaration of a function, but a pointer you can use to
call a function.

Is this the answer you were looking for? If not, let us know what
DEVICE_REQUEST is.

--
BR, Vladimir


zh*********@gmail.com wrote:

static void (DEVICE_REQUEST)(void);

What does this line declare in C?
I am always meeting some codes like this,but I have never learnt that
before.
It looks like a declaration of a function,but why DEVICE_REQUEST has to
be quoted by ( ).



It is. The parentheses are optional, but if a function-like macro named
DEVICE_REQUEST is defined, the parentheses prevent macro substitution.

--
Thad


zh*********@gmail.com said:

static void (DEVICE_REQUEST)(void);

What does this line declare in C?
A function called DEVICE_REQUEST, which takes no parameters and returns no
value, and which has internal linkage.
I am always meeting some codes like this,but I have never learnt that
before.
It looks like a declaration of a function,but why DEVICE_REQUEST has to
be quoted by ( ).



If some clown has done

#define DEVICE_REQUEST(x) someexpressioninvolving x

the parentheses stop the preprocessor from performing the usual
substitution. The definition and call would have to be similarly
parenthesised:

void (DEVICE_REQUEST)(void)
{
;
}

int main(void)
{
(DEVICE_REQUEST)();
return 0;
}

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


这篇关于这在C中是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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