On Fri, Jan 11, 2019 at 10:43:25AM +0100, Stefan Fritsch wrote:
<snip> 
> /* only used for sizeof, not actually allocated */
> extern struct virtio_pci_common_cfg ccfg;
<snip> 
> #define CREAD(sc, memb)  _cread(sc, \
>     offsetof(struct virtio_pci_common_cfg, memb), sizeof(ccfg.memb))
> 
> The compiler should optimize this to the same code as the complicated 
> macro above. You think this variant is acceptable?

Maybe I'm missing something, but these are the more idiomatic constructs

  sizeof ((struct virtio_pci_common_cfg *)0)->memb
  sizeof ((struct virtio_pci_common_cfg){ 0 }).memb

Reply via email to