[previous] 0698 [next] [C] String literal used to initialize an object of incompatible type.
Constraint violations REFERENCE - ISO:C90-6.5.7 Initialization - Semantics, ISO:C90-6.3.16.1 Simple Assignment - Constraints

This is a constraint error

A string literal or a wide string literal is being used to initialize an object of incompatible type.

A string literal is a constant of type 'array of char'. It can only be used to initialize an object of type "pointer to char" or "pointer to void", or an array of type char.

A wide string literal is a constant of type 'array of wchar_t'. It can only be used to initialize an object of type "pointer to wchar_t" or "pointer to void", or an array of type wchar_t.

For example:


/*PRQA S 2017,3122,3132,3205,3210,3408,3447,3602,3625 ++*/


extern int ga[10];

void foo(void)
{
    signed short   ss = "abc";    /* Message 0698 */
    signed int     si = "abc";    /* Message 0698 */
    signed long    sl = "abc";    /* Message 0698 */

    unsigned short us = "abc";    /* Message 0698 */
    unsigned int   ui = "abc";    /* Message 0698 */
    unsigned long  ul = "abc";    /* Message 0698 */

    char           pc = "abc";    /* Message 0682 */
    signed char    sc = "abc";    /* Message 0682 */
    unsigned char  uc = "abc";    /* Message 0682 */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents