C或nesC中struct的语法

时间:2012-10-01 09:00:31

标签: c struct nesc

我有一些nesC代码,并且有一些固定的定义,如下例所示:

typedef nx_struct serial_header {
  nx_am_addr_t dest;
  nx_am_addr_t src;
  nx_uint8_t length;
  nx_am_group_t group;
  nx_am_id_t type;
} serial_header_t;

我无法理解为什么在第一行中他们写了serial_header,而在最后一行写了serial_header_t。我想知道哪一个是这个结构的实际名称,最后一行中添加的_t是什么意思?

1 个答案:

答案 0 :(得分:1)

1)你可以假设serial_header_t等同于nx_struct serial_header,因此你可以在程序中声明变量          serial_header_t nx1;

注意:您不需要使用nx_struct serial_header。

2)如果您错过了typedef并且简单声明如下,

nx_struct serial_header {
  nx_am_addr_t dest;
  nx_am_addr_t src;
  nx_uint8_t length;
  nx_am_group_t group;
  nx_am_id_t type;
}

然后,    在源代码中你应该使用:

        nx_struct serial_header nx1;

希望这会有所帮助。