Clarification for Rule 6.1

6.6 Types

Moderators: misra-c, david ward

Post Reply
anuj1085
Posts: 7
Joined: Mon Feb 09, 2015 7:17 am
Company: TCS

Clarification for Rule 6.1

Post by anuj1085 » Mon Apr 06, 2015 10:02 am

The rule says that the plain char should only be used to store character values.

C standards says single character constant for eg. 'X' are int not char. So the following code:

char x = 'A';

is a violation of the rule as in this char x is storing a constant whose type is "int". If this is not the violation then how to interpret this rule as the all single character constants are int according to "c" standards.

misra-c
Posts: 556
Joined: Thu Jan 05, 2006 1:11 pm

Re: Clarification for Rule 6.1

Post by misra-c » Thu Apr 23, 2015 8:18 am

A Technical Corrigendum to MISRA-C:2004 was issued in July 2007. This clarified the status of character constants, by including the sentence.
Character values/data are character constants or string literals such as 'A', '5', '\n', "a".
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “6.6 Types”