реклама на сайте
подробности

 
 
> Обьявление битовых полей
msalov
сообщение Mar 10 2008, 15:28
Сообщение #1


Знающий
****

Группа: Свой
Сообщений: 526
Регистрация: 24-08-07
Из: Беларусь, Минск
Пользователь №: 30 045



Имею конструкцию:
Код
typedef union {
    struct {
        unsigned langID        :2;
        unsigned unitsID    :1;
        unsigned ED_Level1    :1;
        unsigned ED_Level2    :1;
        unsigned EDR_Level1    :1;
        unsigned EDR_Level2    :1;
        unsigned        :0;

        unsigned Al_Sound    :2;
        unsigned Al_Light    :1;
        unsigned Al_Vibro    :1;
        unsigned        :0;

        unsigned Display    :2;
        unsigned Backlight    :2;
        unsigned Contrast    :3;
        unsigned        :0;
    };
    unsigned char all[3];
} Settings_t;
Settings_t settings;
settings.all[0] = 0x00;
settings.all[1] = 0x01;
settings.all[2] = 0x02;

Имеется стандарт:
Цитата
6.7.2.1 Structure and union specifiers
11. A bit-field declaration with no declarator, but only a colon and a width, indicates an
unnamed bit-field.105) As a special case, a bit-field structure member with a width of 0
indicates that no further bit-field is to be packed into the unit in which the previous bit-field, if any, was placed.

Если я правильно понял стандарт, то байты будут начинаться с полей langID, Al_Sound и Display. Но это оказывается не так
Прикрепленное изображение

Обьясните где я ошибся пожалуйста.
Go to the top of the page
 
+Quote Post

Сообщений в этой теме


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 2nd August 2025 - 19:06
Рейтинг@Mail.ru


Страница сгенерированна за 0.01384 секунд с 7
ELECTRONIX ©2004-2016