According to the C Standard, section subsection 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.
Section Subsection 6.11.6 states that
The use of function declarators with empty parentheses (not prototype-format parameter type declarators) is an obsolescent feature.
...
Failure to declare a void
parameter will result in
- an An ambiguous functional interface between the caller and callee.
- sensitive Sensitive information outflow.
A similar recommendation deals with parameter type in a more general sense: DCL07-C. Include the appropriate type information in function declarators.
...
Code Block | ||||
---|---|---|---|---|
| ||||
/* inIn foo.h */ void foo(); /* inIn foo.c */ void foo() { int i = 3; printf("i value: %d\n", i); } /* inIn caller.c */ #include "foo.h" foo(3); |
...
Code Block | ||||
---|---|---|---|---|
| ||||
/* inIn foo.h */ void foo(void); /* inIn foo.c */ void foo(void) { int i = 3; printf("i value: %d\n", i); } /* inIn caller.c */ #include "foo.h" foo(3); |
...
Code Block | ||||
---|---|---|---|---|
| ||||
/* compileCompile using gcc4.3.3 */ void foo() { /* useUse asm code to retrieve i * implicitly from caller * and transfer it to a less privileged file */ } ... /* callerCaller */ foo(i); /* i is fed from user input */ |
...
Bibliography
[ISO/IEC 9899:2011] | Section Subclause 6.7.6.3, "Function Declarators (including Prototypes)" Section Subclause 6.11.6, "Function Declarators" |
[TIGCC, void usage] | Manual, "C Language Keywords": void |
...