这个C语法有什么用- 使用'K&R'样式函数声明?
int func (p, p2)
void* p;
int p2;
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我能够在Visual Studios 2010beta中写这个
// yes, the arguments are flipped
void f()
{
void* v = 0;
func(5, v);
}
Run Code Online (Sandbox Code Playgroud)
我不明白.这种语法有什么意义?我可以写:
int func (p, p2)
int p2;
{
return 0;
}
// and write
int func (p, p2)
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它似乎唯一指定的是它使用了多少参数和返回类型.我猜没有类型的参数有点酷,但为什么允许它和int paranName函数声明后?有点奇怪.
这还是标准的C吗?
c function kernighan-and-ritchie function-declaration function-definition
我最近在玩GNU Bison的时候看过这样的一些函数定义:
static VALUE
ripper_pos(self)
VALUE self;
{
//code here
}
Run Code Online (Sandbox Code Playgroud)
为什么self括号外的类型?这是有效的C吗?