![]() |
![]() |
0682 | ![]() |
||||
![]() | |||||||
| Constraint violations | REFERENCE - ISO:C90-6.5.7 Initialization - Semantics, ISO:C90-6.3.16.1 Simple Assignment - Constraints | ||||||
This is a constraint error An object of type 'char', 'signed char', 'unsigned char' or 'wchar_t' is being initialized with a string literal. A string literal has type 'array of char' and can only be used to initialise an object of compatible pointer type or array type. An object of type 'char' can only be initialised with an integral constant expression, for example a character constant. For example:
/*PRQA S 753,2017,2211,3122,3132,3205,3408,3604,3625 ++*/
extern void foo(void)
{
char h1 = "Y"; /* Message 0682 */
char h2 = "hello\n"; /* Message 0682 */
char buf[2] = "Y"; /* OK */
char *pc = "hello\n"; /* OK */
}
MISRA C:2012 Rules applicable to message 0682:
| 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 |
See also:
![]() | ||
| 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 |