c - Struct with union: structure has no member named -


this question has answer here:

i have following structures:

struct sched_param {     union {         int sched_priority;         struct lshort_sched_param lshort_params;     }; };  struct lshort_sched_param {     int requested_time;     int level; }; 

whenever make sched_param param1 structure , try update param1.sched_priority field message written in topic.

struct sched_param param1; param1.sched_priority = 1; 

but, whenever make sched_param param2 , try update param2.lshort_params.level works good.

struct sched_param param2; param2.lshort_params.level= 1; 

what reason?

it because version of gcc compiler using not support unnamed union. see stackoverflow link


Comments

Popular posts from this blog

javascript - Wordpress slider, not displayed 100% width -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -