我有一些 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)您可以假设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;
希望这有帮助。
关于c - C 或 nesC 中结构体的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12670240/