...
A similar rule deals with parameter type in a more general sense: DCL07-C. Include the appropriate type information in function declarators.
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 will then take arbitrary parameters.
Noncompliant Code Example (Ambiguous Interface)
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Other Languages
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.
References
Wiki Markup |
---|
\[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\] Forward and Section 6.9.1, "Function definitions" \[[C void usage|http://tigcc.ticalc.org/doc/keywords.html#void]\] |