Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

According to section Section 6.7.5.3, Function declarators Declarators (including prototypesIncluding Prototypes), paragraph 14, of C99:

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. 124^124)
124^124) See "future language directions" (6.11.6).

Section 6.11.6, Function declaratorsDeclarators, states that:

The use of function declarators with empty parentheses (not prototype-format parameter type declarators) is an obsolescent feature.

...

Wiki Markup
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 void usage|http://tigcc.ticalc.org/doc/keywords.html#void]\]. Consequently, function calling with arbitrary parameters will be accepted without a warning at compile time.

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...

Related Guidelines

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.

...