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.

CCS中的pragma问题



CCS不能用#pragma pack(push),#pragma pack(pop),#pragma pack(1)。我知道有#pragma DATA_ALIGN但在如下代码中我该怎样做修改

#pragma pack(push)
#pragma pack(1) //按字节对齐

typedef struct
{
uint8 cmd_head; //帧头

uint8 cmd_type; //命令类型(UPDATE_CONTROL)
uint8 ctrl_msg; //CtrlMsgType-指示消息的类型
uint16 screen_id; //产生消息的画面ID
uint16 control_id; //产生消息的控件ID
uint8 control_type; //控件类型

uint8 param[256];//可变长度参数,最多256个字节

uint8 cmd_tail[4]; //帧尾
}CTRL_MSG,*PCTRL_MSG;

#pragma pack(pop)

  • 结构体中成员1byte对齐可以试试下面的写法。
    struct __attribute__((__packed__)) packed_struct { char c1; int i; char c2; }; 

    6.15.4 Type Attributes
    http://www.ti.com/lit/ug/spru187u/spru187u.pdf 

  • 我这样写的

    struct __attribute__((__packed__)) CTRL_MSG
    {
    uint8 cmd_head; //帧头

    uint8 cmd_type; //命令类型(UPDATE_CONTROL)
    uint8 ctrl_msg; //CtrlMsgType-指示消息的类型
    uint16 screen_id; //产生消息的画面ID
    uint16 control_id; //产生消息的控件ID
    uint8 control_type; //控件类型

    uint8 param[256];//可变长度参数,最多256个字节

    uint8 cmd_tail[4]; //帧尾
    };
    typedef CTRL_MSG* PCTRL_MSG;

    报了这样的错误error #1167: invalid attribute for "struct CTRL_MSG"

                                 error #20: identifier "CTRL_MSG" is undefined

    该怎么解决呢?

  • C2000的编译器不支持此类用法吗?