[previous] 3626 [next] Double-quote character in a character constant is not preceded by a backslash character.
Constants

This character constant defines a double-quote character ("). An escape sequence representation may be preferred.

When a double-quote character is required in a string literal, it must be represented using an escape sequence (\") - so that it doesn't become the string terminator. However, this isn't essential in a character constant.

Similarly, when a single-quote character (') is to be represented in a character constant, it must be represented using an escape sequence (\'); but this isn't necessary in a string literal.

Some coding standards recommend that, for consistency, all single-quotes and double-quotes should be coded using escape sequences whether they occur in character constants or string literals.

For example:


/*PRQA S 2017,3123,3211,3408,3602,3625 ++*/

char pca = '"';                                 /* Message 3626 */
char pcb = '\"';                                /*              */
char pcc = '\'';                                /*              */

const char * psa = "an apostrophe:     '";      /* Message 3627 */
const char * psb = "an apostrophe:    \'";      /*              */
const char * psc = "a quotation mark: \"";      /*              */

See also:

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