[previous] 0683 [next] [C] Initializer for object of a character type is a wide string literal.
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 wide string literal. A wide string literal has type 'array of wchar_t' and can only be used to initialise an object of compatible pointer type or array type. An object of type wchar_t can only be initialised with an integral constant expression, for example a wide character constant.

For example:


/*PRQA S 284,753,878,2017,2213,3122,3123,3211,3408,3410,3429,3453,3674 ++*/

#include <stddef.h>


wchar_t wc1   = L'ab';                    /* OK */
wchar_t wc2   = L"ab";                    /* Message 0683 */
wchar_t * wp1 = L"ABCDEF";                /* OK */
wchar_t * w[] = {L"ABCDEF"};              /* OK */


MISRA C:2012 Rules applicable to message 0683:

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