![]() |
![]() |
3607 | ![]() |
||||
![]() | |||||||
| Functions | REFERENCE - ISO:C90-6.5.4.3 Function Declarators (including Prototypes) - Semantics | ||||||
A function parameter is being declared as a function in an old style function definition. In an old (pre-ISO) compiler, this syntax might not even be supported. However, according to the ISO:C90 standard, a function parameter declared in this way will actually be interpreted as a "pointer to function". In any case, it would be much clearer to declare it explicitly as a "pointer to function". For example:
/*PRQA S 1304,3002,3199,3203,3206,3227,3408,3672 ++*/
/**************************
* OLD-STYLE FUNCTIONS
**************************/
extern int foo1(fa) /* Message 3607 - fa is declared as a "function" */
int fa(int p);
{
int (*fp)(int p);
fp = fa;
return 1;
}
extern int foo2(fb) /* No message - fb is declared as a "pointer to function" */
int (*fb)(int p);
{
int (*fp)(int p);
fp = fb;
return 1;
}
/**************************
* NEW-STYLE FUNCTIONS
**************************/
extern int foo3(int fc(int p)) /* No message - fc is declared as a "function" */
{
int (*fp)(int p);
fp = fc;
return 1;
}
extern int foo4(int (*fd)(int p)) /* No message - fd is declared as a "pointer to function" */
{
int (*fp)(int p);
fp = fd;
return 1;
}
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |