I just discovered that the open () system call (man 2 open) has two versions:
int open(const char *pathname, int flags); int open(const char *pathname, int flags, mode_t mode);
Indeed, it can be used either in a single C file, and both will work. How can standard C achieve this?
Actually, this is not an overload of a C ++ style function. It is just that open() is a variable:
open()
int open(const char *fname, int flags, ...);
And only if flags are required for this, will he look for a third argument.
This can be done as a variable function of the argument.
The POSIX documentation for open defines this as follows:
open
int open(const char *path, int oflag, ...);