Since C does not support method overloading, how is it possible to have methods like open
, that explicitly offers two different signatures:
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
I mean, printf
supports a variate number of arguments using vargs
, but have no definite signature other than the one using vargs
itself -- otherwise there should be one signature for each possible printf
call. Yet, open()
-- as I presume -- is written in C, and offers two explicit signatures.
I didn't actually get the way these functions are implemented. Can someone show a small example of how a function like:
void foo() { printf("bar\n"); }
void foo(int x) { printf("bar %d\n", x); }
would be implemented in C?