Reading glibc, I saw this piece of code in string/strerror.c
:
char *
strerror (errnum)
int errnum;
{
char *ret = __strerror_r (errnum, NULL, 0);
int saved_errno;
if (__glibc_likely (ret != NULL))
return ret;
saved_errno = errno;
if (buf == NULL)
buf = malloc (1024);
__set_errno (saved_errno);
if (buf == NULL)
return _("Unknown error");
return __strerror_r (errnum, buf, 1024);
}
Note how there is a int errnum
following the argument list. How is this a valid syntax? And what is it doing?
That's the old-style way of doing things, K&R, pre-ANSI.
Once function prototypes were introduced, this way of doing things was rendered obsolete.
Not actually obsolete since it's still valid even in C11 (as per 6.9.1 Function definitions /13
), but few people use it any more).
It's specifying the type of the parameter for the function block, similar to:
char *strerror (int errnum)