3 ms·
You've probably been reading C++ material. Only in C++ int f(); and int f(void); are identical. In C, however, int f(); Declares a function taking
by pmjordan 16y ago
You've probably been reading C++ material. Only in C++
int f();
and
int f(void);
are identical.
In C, however,
int f();
Declares a function taking any number of arguments. In C++, that would be denoted as
int f(...);
Which is unfortunately a syntax error in traditional C as the ellipsis is only allowed following some explicit parameters. (It's not that big a deal; you'd have to
#ifdef __cplusplus
extern "C"
#endif
in the header of the C library for C++ compatibility anyway (to prevent function name mangling and thus link errors), so you can #ifdef the () and (...) too.)
FWIW, C++ does support the legacy
int f(void);
syntax, but its use is discouraged except for headers which are also to be used for C code.