According to the C Standard, section 6.7.6.3, paragraph 14 [ISO/IEC 9899:2011],
An identifier list declares only the identifiers of the parameters of the function. An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters. The empty list in a function declarator that is not part of a definition of that function specifies that no information about the number or types of the parameters is supplied.
...
Defining a function with a void
argument list differs from declaring it with no arguments because, in the latter case, the compiler will not check whether the function is called with parameters at all [C TIGCC, void usage]. Consequently, function calling with arbitrary parameters will be accepted without a warning at compile time.
...
In C++, foo()
and foo(void)
have exactly the same meaning and effect, so this rule doesn't apply to C++. However, foo(void)
should be declared explicitly instead of foo()
to distinguish it from foo(...)
, which accepts an arbitrary number and type of arguments.
Bibliography
...
] | Foreword and section 6.9.1, "Function |
---|
...
Definitions" |
---|
Bibliography
[ |
...
TIGCC, void usage] | Manual, "C Language Keywords": void |
...