![]() |
![]() |
3001 | ![]() |
||||
![]() | |||||||
| Functions | REFERENCE - ISO:C90-6.5.4.3 Function Declarators (Including Prototypes) - Semantics, ISO:C90-6.9.4 Future Language Directions | ||||||
A function declaration with an empty parameter-list is described as an old style declaration. The problem with this sort of declaration is that it imparts no information about the number of parameters in the function interface or, indeed, whether there are any parameters at all. It is therefore impossible for any checking to be performed on a subsequent function call. Notice that the meaning of an empty parameter-list is different in the C++ language; it means that the function has no parameters. If a function has no parameters, it should always be declared with a parameter list of "void". If the function does use parameters, a new style prototype declaration should be used. For example:
/*PRQA S 1303,2017,3198,3227,3408,3447 ++*/
extern int f1(void);
extern int f2(); /* Message 3001 */
extern int foo(int n)
{
int r;
r = f1(n); /* Message 0423 - constraint error */
r = f2(n); /* Number and type of parameters cannot be checked */
return r;
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |