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.

芯片DSP28377D,软件CCS6,如何设置字节对齐?



typedef struct MBX_STRUCT_PACKED_START

{

    UINT16                          Length; /**< \brief Length*/

    UINT16                          Address; /**< \brief Address*/

 

    UINT8                           Flags[2]; /**< \brief Flags*/

   

}MBX_STRUCT_PACKED_END

如上述的结构体,CCS6默认是16位对齐方式,这样Flags[0]占用一个地址、Flags[1]占用另一个地址;

请问如何设置使Flags[1]占用地址的高8位、Flags[0]占用地址的低8位?

即如何对CCS6进行设置,使后续8位大小的数据可以组合占用一个地址?

  • 在结构体中可以直接指定对应的位,像这样:

      UINT16                          Length; /**< \brief Length*/

      UINT16                          Address; /**< \brief Address*/

     

       UINT8                           Flags[0] :8;

       UINT8                           Flags[1] :8;