[cfe-dev] Struct padding

Hongbin Zheng via cfe-dev cfe-dev at lists.llvm.org
Thu May 18 00:15:04 PDT 2017


Hi,

I am wondering how I can tell whether a field of a struct is introduced by
padding or not.

For example, if I have a struct:

struct foo1 {
    char *p;     /* 8 bytes */
    char c;      /* 1 byte
    long x;      /* 8 bytes */
};

clang may generate:

struct foo1 {
    char *p;     /* 8 bytes */
    char c;      /* 1 byte
    char pad[7]; /* 7 bytes */
    long x;      /* 8 bytes */
};

Is there any way that I can tell the "pad" array is generated by padding?

Thanks a lot
Hongbin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170518/ff0f0d67/attachment.html>


More information about the cfe-dev mailing list