...
Attempting to compile a program with a function declarator that does not include the appropriate type information typically generates a warning but does not prevent program compilation. These warnings should be resolved. (See MSC00-C. Compile cleanly at high warning levels.)
Noncompliant Code Example (Non-Prototype-Format Declarators)
...
Declaring a function without any prototype forces the compiler to assume that the correct number and type of parameters have been supplied to a function. This can result in unintended and undefined behavior.
In this noncompliant code example, the definition of func()
in file_a.c
expects three parameters but is supplied only two.
...
C99 eliminated implicit function declarations from the C language. However, many compilers still allow the compilation of programs containing implicitly declared functions, although they may issue a warning message. These warnings should be resolved. (See MSC00-C. Compile cleanly at high warning levels.)
Compliant Solution (Function Prototypes)
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
| 21 S | Fully implemented. | |||||||
GCC |
|
| Can detect violation of this recommendation when the | ||||||
| decltype | Fully implemented. | |||||||
PRQA QA·CQA-C |
| Fully implemented |
...
ISO/IEC 9899:2011 Forward and Section 6.9.1, "Function definitions"
ISO/IEC TR 24772 "IHN Type system" and "OTR Subprogram signature mismatch"
MISRA Rule 8.2
Bibliography
[Spinellis 2006] Section 2.6.1, "Incorrect routine or arguments"
...