我最近在玩GNU Bison的时候看过这样的一些函数定义:
static VALUE
ripper_pos(self)
VALUE self;
{
//code here
}
Run Code Online (Sandbox Code Playgroud)
为什么self
括号外的类型?这是有效的C吗?
这是一个简单的函数delcared并使用旧样式语法定义:
#include <stdio.h>
void
error(message,a1,a2,a3,a4,a5,a6,a7)
char *message;
char *a1,*a2,*a3,*a4,*a5,*a6,*a7;
{
fprintf(stderr,message,a1,a2,a3,a4,a5,a6,a7);
}
int main ()
{
error("[ERROR %d]: %s.\n",110,"Connection timed out");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它可以编译并正确运行以进行打印:
[ERROR 110]:连接超时.
我读到这个样式没有相关的原型,但是如何在运行时自动将int转换为char*,甚至提供的参数少于声明的参数?