What is this strange function definition syntax in C? [duplicate]
Those are old K&R style function parameter declarations, declaring the types of the parameters separately:
int func(a, b, c)
int a;
int b;
int c;
{
return a + b + c;
}
This is the same as the more modern way to declare function parameters:
int func(int a, int b, int c)
{
return a + b + c;
}
The "new style" declarations are basically universally preferred.
This is the so-called "old" variant of declaring function arguments. In ye olden days, you couldn't just write argument types inside the parentheses, but you had to define it for each argument right after the closing parenthesis.
In other words, it is equivalent to ripper_pos( VALUE self )
Yes, it uses an older style of function definition in which the parameters, sans type, are listed in parentheses, followed by the declaration of those variables with their types before the opening brace of the function body. So self
is of type VALUE
.
This is old c. K&R C used this convention, before ANSI C enforced typed parameters.
static VALUE // A static function that returns 'VALUE' type.
ripper_pos(self) // Function 'ripper_pos' takes a parameter named 'self'.
VALUE self; // The 'self' parameter is of type 'VALUE'.