...
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 (
...
NonPrototype-Format Declarators)
The noncompliant code example uses the identifier-list form for parameter declarations.
...
Section 6.11 of the C99 standard, "Future language directions," states that "The use of function definitions with separate parameter identifier and declaration lists (not prototype-format parameter type and identifier declarators) is an obsolescent feature."
Compliant Solution (
...
NonPrototype-
...
Format Declarators)
In this compliant solution, int
is the type specifier, max(int a, int b)
is the function declarator, and the block within the curly braces is the function body.
...
In this noncompliant code example, the definition of func()
in file_a.c
expects three parameters but is supplied only two.
...
Code Block | ||
---|---|---|
| ||
/* file_b.c source file */ int func(int, int, int); func(1, 2, 3); |
DCL14-C. Do not make assumptions about the order of global variable initialization across translation units, shows how to use header files to accomplish this same goal in a more maintainable fashion.
...