void参数参数 [英] void parameter argument

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

问题描述

仅仅是我,还是删除了对void这个词的支持。在一个

参数列表中非常讨厌?我们中的一些人已经编程为

年推出void function_name(void) - 它真的不舒服

不得不错过它。有没有理由让他们删除这个?我不是没有b $ b假设有一个pragma或什么来阻止编译器对它的咆哮

有吗?

Is it just me, or is the removal of support for the word "void" in a
parameter list extremely annoying? Some of us have been programming for
years putting "void function_name (void)" - and it really doesn''t feel nice
having to miss it out. Is there any reason for them removing this? I don''t
suppose there''s a pragma or something to stop the compiler barking about it
is there?

推荐答案

AFAIK,语法


void function_name(void)


是在ANSI C中引入的(或者可能更早)因为旧的,原始的&b $ b K& RC允许具有未指定的原型的原型。参数。所以,在

C中你也可以说,


void function_name()


其中_not_ mean" ;此函数不带任何参数,但是

而不是我不是在告诉你这个函数需要什么参数,如果

any。所以,(void)语法是一个必要的补充,以区分

这个不公开和声明函数没有

参数。这是一个向后兼容的东西。


我认为它在C#中被遗漏了,因为它是多余的。在要求您声明所有参数的

语言中,没有必要使用关键字void来区分这两种情况。

AFAIK, the syntax

void function_name(void)

was introduced in ANSI C (or perhaps earlier) because the old, original
K&R C allowed function prototypes with "unspecified" arguments. So, in
C you could also say,

void function_name()

which did _not_ mean "this function does not take any arguments," but
rather "I''m not telling you what arguments this function takes, if
any." So, the "(void)" syntax was a necessary addition to distinguish
between this non-disclosure and a declaration that a function took no
arguments. It was a backward compatibility thing.

I suppose that it was left out in C# because it''s superfluous. In a
language that requires you to declare all arguments, there''s no need to
distinguish between the two cases with a keyword "void".


Dan写道:
这只是我,还是取消了对void这个词的支持在
参数列表中非常烦人?我们中的一些人已经编程了
年推出void function_name(void) - 它真的不是很好,不得不错过它。有没有理由让他们删除这个?我不认为有一个pragma或什么东西阻止编译器对它咆哮
有吗?
Is it just me, or is the removal of support for the word "void" in a
parameter list extremely annoying? Some of us have been programming for
years putting "void function_name (void)" - and it really doesn''t feel nice
having to miss it out. Is there any reason for them removing this? I don''t
suppose there''s a pragma or something to stop the compiler barking about it
is there?




但是你有键入较少,那么有什么大不了的? )。只是习惯了

()意味着(没有)或(无效)或(虚无)你已经完成了:)


FB


-

------------------------------- -----------------------------------------

Get LLBLGen Pro,适用于.NET的高效O / R映射: http://www.llblgen.com

我的.NET博客: http://weblogs.asp。 net / fbouma

Microsoft MVP(C#)

---------------------- --------------------------------------------------



But you have to type less, so what''s the big deal? ;). Just get used to
() means (nothing) or (void) or (nada) and you''re done :)

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------


> >是仅仅是我,还是删除了对void这个词的支持。在
> > Is it just me, or is the removal of support for the word "void" in a
参数列表非常讨厌?我们中的一些人已经编程了
年推出void function_name(void) - 它真的不觉得
不错,不得不错过它。有没有理由让他们删除这个?我b $ b不要以为有一个pragma或什么来阻止编译器咆哮
它在那里?
parameter list extremely annoying? Some of us have been programming for
years putting "void function_name (void)" - and it really doesn''t feel nice having to miss it out. Is there any reason for them removing this? I don''t suppose there''s a pragma or something to stop the compiler barking about it is there?



但是你必须输入更少,那有什么大不了的? )。刚习惯
()意味着(没有)或(无效)或(虚无),你已经完成了:)



But you have to type less, so what''s the big deal? ;). Just get used to
() means (nothing) or (void) or (nada) and you''re done :)



不幸的是,在工作中它是'我们的编码标准的一部分,你必须把

" void"在没有参数的函数中(我们在工作中使用C)。所以我不能得到

以前不使用它。


Unfortunately, at work it''s part of our coding standard that you have to put
"void" in a function without parameters (we use C at work). So I can''t get
used to not using it.


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

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