<分区>
我最近在玩 GNU Bison 时看到了一些这样的函数定义:
static VALUE
ripper_pos(self)
VALUE self;
{
//code here
}
为什么 self
的类型在括号外?这是有效的 C 吗?
标签 c function definition
<分区>
我最近在玩 GNU Bison 时看到了一些这样的函数定义:
static VALUE
ripper_pos(self)
VALUE self;
{
//code here
}
为什么 self
的类型在括号外?这是有效的 C 吗?
最佳答案
那些是旧的 K&R 风格的函数参数声明,分别声明参数的类型:
int func(a, b, c)
int a;
int b;
int c;
{
return a + b + c;
}
这与更现代的函数参数声明方式相同:
int func(int a, int b, int c)
{
return a + b + c;
}
“新式”声明基本上是普遍首选。
关于c - C中这个奇怪的函数定义语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23057520/