![]() |
![]() |
3625 | ![]() |
||||
![]() | |||||||
| Declarations and Definitions | REFERENCE - ISO:C90-6.1.2.5 Types | ||||||
Type char has been used in the definition of an object or function. Type char may be implemented as either a signed or an unsigned type, but it is always a distinct type and should not be considered synonymous with either signed char or unsigned char. Some coding standards have attempted to prohibit the use of type char and recommend using signed char or unsigned char instead - in order to avoid implementation defined behaviour. However, this is a simplistic approach which can lead to further problems. A better approach is to maintain a clear distinction between 'character' data and 'numeric' data. Type char should be used for the former; signed char and unsigned char should be used for the latter. The code example below demonstrates various messages which exist to identify the use of type char.
/*PRQA S 2017,3120,3198,3199,3203,3205,3210,3408,3447,3448 ++*/
typedef char TCH; /* Message 3632 */
extern char cha; /* Message 3625 */
extern TCH chb; /* */
extern void foo(void)
{
unsigned long ur;
cha = (char)0x0dU; /* Message 3631 */
chb = (TCH)0x0dU; /* */
ur = (unsigned long)sizeof(char *); /* Message 3633 */
ur = (unsigned long)sizeof(TCH *); /* */
}
No MISRA C:2012 Rules applicable to message 3625
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 |