[previous] MISRA-C:2004  Rule  4.1:  (Required) [next] Only those escape sequences that are defined in the ISO C standard shall be used.
Only "simple-escape-sequences" in ISO/IEC 9899:1990 [3-6] Section 6.1.3.4 and \0 are permitted escape sequences.
All "hexadecimal-escape-sequences" are prohibited.
The "octal-escape-sequences" other than \0 are also prohibited under Rule 7.1.

Example Code:


/* PRQA S 3205 ++ */

#include "misra.h"
#include "m2cmex.h"


extern S16 test_0401( void )
{
   /* ISO-C Escape sequences */
   PC esa = '\a';
   PC esb = '\b';
   PC esf = '\f';
   PC esn = '\n';
   PC esr = '\r';
   PC est = '\t';
   PC esv = '\v';


   /* Numeric escape sequences */
   PC esx = '\x0D';
   PC es15 = '\15';


   /* Non-conforming escape sequences */
   PC esc = '\c';                        /* MISRA Violation */
   PC esd = '\d';                        /* MISRA Violation */
   PC ese = '\e';                        /* MISRA Violation */
   PC esg = '\g';                        /* MISRA Violation */
   PC esh = '\h';                        /* MISRA Violation */
   PC esi = '\i';                        /* MISRA Violation */
   PC esj = '\j';                        /* MISRA Violation */
   PC esk = '\k';                        /* MISRA Violation */
   PC esl = '\l';                        /* MISRA Violation */
   PC esm = '\m';                        /* MISRA Violation */
   PC eso = '\o';                        /* MISRA Violation */
   PC esp = '\p';                        /* MISRA Violation */
   PC esq = '\q';                        /* MISRA Violation */
   PC ess = '\s';                        /* MISRA Violation */
   PC esu = '\u';                        /* MISRA Violation */
   PC esw = '\w';                        /* MISRA Violation */
   PC esy = '\y';                        /* MISRA Violation */
   PC esz = '\z';                        /* MISRA Violation */
   return 0;
}


QAC messages that encompass this guideline:

0235 [U] Unknown escape sequence.
3610 Hexadecimal escape sequence used.


Related rules:

Rule  1.2 No reliance shall be placed on undefined or unspecified behaviour.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents