This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

怎么定义使用8位数据类型



大家好,

因为C2000的存储单位是16位,但是有些地方需要8位对齐,所以想问下以下这种方式的位能不能对齐:

typedef unsigned char uint8;  //宏定义数据类型

union
{
    uint8 M;
    struct {
        uint8 A   :1;
        uint8 B   :1;
        uint8 C   :1;
        uint8 D   :1;
        uint8 E   :1;
        uint8 F   :1;
        uint8 G   :1;
        uint8 H   :1;
    }Y;
}Test;

这种情况是不是只需要考虑低8位,高8位的值就对A~H没有影响了?

对整体赋值时可不可以Test.M=XXX,?