struct ifreq {
char ifr_name[IFNAMSIZ];
union {
caddr_t ifr_d;
} ifr;
};
Here they have used union, I didn’t get the point why have they used when there is only one element used there?
I have a idea of using union only if there are 2-3 elements that need to be used.
Thanks
Loads of possibilities. But, in this case, it looks like it’s because the definition was cut out of the corresponding Linux header, and they just took the parts they needed.
struct ifreqlooks like this, normally: