0

I have some nesC code, and there is some sturct definitions like the example below:

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;

I cant get the idea why in the first line they wrote serial_header while in the last line they wrote serial_header_t. I am wondering which one is the actual name of this struct and what does that _t added in the last line means?

Dumbo
  • 13,555
  • 54
  • 184
  • 288

1 Answers1

1

1) you can assume that serial_header_t is equivalent to nx_struct serial_header, and because of that you can declare the variable in the program like serial_header_t nx1;

NOTE: you do not need to use nx_struct serial_header.

2) In case you miss typedef and simple declare like the following way,

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;
}

then, in the source code you should use like:

        nx_struct serial_header nx1;

Hope this helps.

Whoami
  • 13,930
  • 19
  • 84
  • 140