Rule 6.1

Moderators: misra-c, david ward

Akhil
Posts: 4
Joined: Mon Aug 12, 2013 10:12 am
Company: TCS

Rule 6.1

Postby Akhil » Wed Jan 15, 2014 6:48 am

In the Amplification for Rule 6.1 :

For C99 : The appropriate types are :

1. either unsigned or signed int.
This refers to unsigned int and signed int only OR any other datatype..?

2. Another explicitly signed or explicitly unsigned integer type that is premitted by the implementation.
What all types does this refer to ? Does this refer to unsigned short OR unsigned short int etc.

Please clarify.

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

Re: Rule 6.1

Postby misra-c » Tue Jan 21, 2014 9:17 am

Paragraph 4 of the constraints section 6.7.2.1 of the C99 standard states:
"A bit-field shall have a type that is a qualified or unqualifed version of _Bool, signed int, unsigned int or some other implementation-defined type."

The phrase "implementation-defined type" refers to both
* standard integer types (excluding unsigned int and signed int)
and
* implementation-defined extended integer types
providing your implementation supports those types in a bit-field declaration.

Going back to your question.
"unsigned and signed int" bit-fields are permitted by all implementations and will always be compliant with this rule.

Other explicitly signed integer types such as "unsigned short" may or may not be compliant with this rule, depending on whether such types are supported as bit-fields by your implementation.
---
Posted by and on behalf of
the MISRA C Working Group


Return to “8.6 Types”

Who is online

Users browsing this forum: No registered users and 0 guests