C distinguishes between a function declared with an empty parameter list
and a function declared with a parameter list consisting of only
void.
The former is an unprototyped function taking an unspecified number of
arguments, while the latter is a prototyped function taking no arguments.
// C code extern int foo(); // Unspecified parameters extern int bar(void); // No parameters void baz() { foo(0); // Valid C, invalid C++ foo(1, 2); // Valid C, invalid C++ bar(); // Okay in both C and C++ bar(1); // Error in both C and C++ }C++, on the other hand, makes no distinction between the two declarations and considers them both to mean a function taking no arguments.
// C++ code extern int xyz(); extern int xyz(void); // Same as 'xyz()' in C++, // Different and invalid in CFor code that is intended to be compiled as either C or C++, the best solution to this problem is to always declare functions taking no parameters with an explicit void prototype. For example:
// Compiles as both C and C++ int bosho(void) { ... }Empty function prototypes are a deprecated feature in C99 (as they were in C89).
Refer to http://david.tribble.com/text/cdiffs.htm