c - A variable declaration following an argument list -


this question has answer here:

reading glibc, saw 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 int errnum following argument list. how valid syntax? , doing?

that's old-style way of doing things, k&r, pre-ansi.

once function prototypes introduced, way of doing things rendered obsolete.

not actually obsolete since it's still valid in c11 (as per 6.9.1 function definitions /13), few people use more).

it's specifying type of parameter function block, similar to:

char *strerror (int errnum) 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -