Author Topic: Nested struct type...  (Read 1017 times)

joecar

  • Senior Community Member
  • Posts: 177
  • Hero Points: 4
  • engineer/gearhead
Re: Nested struct type...
« Reply #15 on: October 11, 2017, 01:45:49 am »
Good suggestion, thanks.

joecar

  • Senior Community Member
  • Posts: 177
  • Hero Points: 4
  • engineer/gearhead
Nested structure definition...
« Reply #16 on: December 07, 2017, 08:14:52 pm »
Here is another example of this...

interestingly, the symbol is highlighted as Unknown, but Preview shows its definition.

Code: [Select]
struct ct_sns_rsp {
struct {
struct ct_hdr header;
uint16_t response;
uint16_t residual;
uint8_t fragment_id;
uint8_t reason_code;
uint8_t explanation_code;
uint8_t vendor_unique;
};

union {
struct ga_nxt {
uint8_t port_type;
uint8_t port_id[3];
uint8_t port_name[8];
uint8_t sym_port_name_len;
uint8_t sym_port_name[255];
uint8_t node_name[8];
uint8_t sym_node_name_len;
uint8_t sym_node_name[255];
uint8_t init_proc_assoc[8];
uint8_t node_ip_addr[16];
uint8_t class_of_service[4];
uint8_t fc4_types[32];
uint8_t ip_address[16];
uint8_t fabric_port_name[8];
uint8_t reserved;
uint8_t hard_address[3];
} ga_nxt;

struct {
/* Assume largest number of targets for union */
struct gid_pt_entry {
uint8_t control_byte;
uint8_t port_id[3];
} entries[MAX_FIBRE_DEVICES_MAX];
} gid_pt;

struct {
/* Assume largest number of targets for union */
struct ct_sns_gpn_ft_data {
u8 control_byte;
u8 port_id[3];
u32 reserved;
u8 port_name[8];
} entries[MAX_FIBRE_DEVICES_MAX];
} gpn_ft;

struct gpn_id {
uint8_t port_name[8];
} gpn_id;

struct gnn_id {
uint8_t node_name[8];
} gnn_id;

struct {
uint8_t fc4_types[32];
} gft_id;

struct {
uint32_t entry_count;
uint8_t port_name[8];
struct ct_fdmi1_hba_attributes attrs;
} ghat;

struct gfpn_id {
uint8_t port_name[8];
} gfpn_id;

struct {
uint16_t speeds;
uint16_t speed;
} gpsc;

struct {
uint8_t fc4_features[128];
} gff_id;

struct {
uint8_t reserved;
uint8_t port_id[3];
} gid_pn;

struct gfo {
uint32_t count;
struct {
uint16_t type;
uint16_t length;
uint8_t value[8];
} name;
struct {
struct {
uint16_t type;
uint16_t length;
uint8_t value[1];
uint8_t unused[3];
} supported;
struct {
uint16_t type;
uint16_t length;
uint8_t value[4];
} range[3];
} priority;
} gfo;
} rsp;
};

Code: [Select]
static inline uint
qla25xx_gfo_priority(struct gfo *gfo, uint index)
{
if (gfo->priority.supported.value[0])
return gfo->priority.range[index].value[1] & 0x7f;

return 0;
}



« Last Edit: December 07, 2017, 08:18:42 pm by joecar »

joecar

  • Senior Community Member
  • Posts: 177
  • Hero Points: 4
  • engineer/gearhead
Re: Nested struct type...
« Reply #17 on: December 07, 2017, 08:22:44 pm »
I did notice that Preview shows the wrong definition of the sub-member .value...

i.e. Preview shows struct name .value in each of these instances:

   if (gfo->priority.supported.value[0])
             return gfo->priority.range[index].value[1] & 0x7f;


Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2257
  • Hero Points: 283
Re: Nested struct type...
« Reply #18 on: December 07, 2017, 08:48:29 pm »
This will be fixed in the upcoming 22.0.1 maintenance release.

The Preview window tends to go for broke if it can't find a symbol's definition using conventional context tagging, it will just display any symbol with a matching name if all else fails.  It's better than nothing and can be helpful, but knowing that, you have to take what it shows with a grain of salt.  It corresponds with the results you might get if you do a Ctrl+Dot on the same symbol, the tagging engine will try to resolve the symbol using Context Tagging, but if the intelligent stuff fails, it falls back to just finding something with a name that matches.

joecar

  • Senior Community Member
  • Posts: 177
  • Hero Points: 4
  • engineer/gearhead
Re: Nested struct type...
« Reply #19 on: December 08, 2017, 07:55:06 pm »
Ok, thanks.

Thanks for the Preview insight.

 ;)

joecar

  • Senior Community Member
  • Posts: 177
  • Hero Points: 4
  • engineer/gearhead
Re: Nested struct type...
« Reply #20 on: December 12, 2017, 06:05:06 pm »
Also, here is a possibly related example using typeof (gcc)...

p, declared using typeof, is highlighted as Unknown:






Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2257
  • Hero Points: 283
Re: Nested struct type...
« Reply #21 on: December 13, 2017, 12:39:30 am »
I plan to add full support for the typeof() keyword for a future release, even though it is a GNU extension.  The C++11 keyword is decltype().

If you set up your C/C++ Preprocessing to map "typeof(x)" to "decltype(x)", that should solve this case for you.

joecar

  • Senior Community Member
  • Posts: 177
  • Hero Points: 4
  • engineer/gearhead
Re: Nested struct type...
« Reply #22 on: December 13, 2017, 06:04:43 pm »
Ok.  Thanks for the hint.