[previous] 0685 [next] [C] Initializer for any object with static storage duration must be a constant expression.
Constraint violations REFERENCE - ISO:C90-6.5.7 Initialization - Constraints, ISO:C90-6.4 Constant Expressions - Constraints.

This is a constraint error

The initializer for any object with static storage duration must be a constant expression.

For example:


/*PRQA S 2017,3199,3205,3211,3223,3227,3408,3447 ++*/

extern int ga;

int gb = ga;                 /* Message 0685 */

void foo(int n)
{
    static int x = n;        /* Message 0685 */
}


MISRA C:2012 Rules applicable to message 0685:

Rule-1.1  (Required) The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits


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