![]() |
![]() |
3660 | ![]() |
||||
![]() | |||||||
| Arrays, structures, unions and bit-fields | REFERENCE - ISO:C90-6.5.2.1 Structure and Union Specifiers - Semantics | ||||||
A signed bit-field consisting of a single bit is only able to represent the values -1 and 0. This is seldom useful ! It cannot even represent the number 1. For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 3660, 3665, 0634, 2850 --*/
/**************************************
* OPTIONS: -bits+
*************************************/
struct mysignedbit /* Message 0634 */
{
signed int b1:1; /* Message 3660 */
signed int :1; /* Message 3665 */
int b2:1; /* Message 3660 */
int :1; /* Message 3665 */
};
extern void foo(void)
{
struct mysignedbit b;
b.b1 = 0; /* OK */
b.b1 = -1; /* OK */
b.b1 = 1; /* Message 2850 - value "1" cannot be represented ! */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |