![]() |
![]() |
1046 | ![]() |
||||
![]() | |||||||
| Language extensions | |||||||
Default arguments are a C++ specific feature, which is provided as an extension to ISO:C Standard by some compilers. QA C will accept a constant expression or an object identifier as a default argument for a parameter, and use that argument whenever one is not provided explicitly in a function call. This message will be issued for a declaration (but not a definition) of a function with default argument syntax. For example:
/* PRQA S 1-9999 ++ */
/* PRQA S 1046 -- */
extern int f1 (int = 1, char = 0); /* Message 1046 */
extern int gi;
extern int f2 (int = gi); /* Message 1046 */
extern int f3 (int a, char b = 0); /* Message 1046 */
extern int f1 (int a = 1, char b = 0); /* Message 1046 */
int f1 (int a = 11, char b = 10) /* No message */
{
return a + b + f2 () + f2 (0) + f3 (0);
}
MISRA C:2012 Rules applicable to message 1046:
| Rule-1.2 (Advisory) | Language extensions should not be used |
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |