Search code examples
c++clinuxoverloadingglibc

Why does syslog have two different function declarations?


According to the Linux manual pages 1 and 2, the function syslog has two different function declarations as follows:

int syslog(int type, char *bufp, int len);

void syslog(int priority, const char *format, ...);

However, other than C++, there is no function overloading in C.

How to explain the fact?


Solution

  • One is defined in section 2 (syslog(2)) of the manual pages (*), thus a system call. The other one is from section 3 (syslog(3)) thus a C library function.

    So "technically" they are different functions that happen to have the same name (albeit they are related of course, as (3) is using (2)).

    (*) See manual page sections.