<div dir="ltr"><div class="gmail_default"><font color="#20124d" face="tahoma, sans-serif">Hi Hongbin,</font></div><div class="gmail_default"><font color="#20124d" face="tahoma, sans-serif"><br></font></div><div class="gmail_default"><font color="#20124d" face="tahoma, sans-serif">You can pass `-Wpadded` to clang. For your particular example it will print something along the lines of <br><br>```<br><div class="gmail_default">warning: padding struct 'foo1' with 7 bytes to align 'x' [-Wpadded]</div><div class="gmail_default"> long x;</div><div class="gmail_default">```</div><div class="gmail_default"><br></div><div class="gmail_default">Jonas</div></font></div><div class="gmail_extra">
<br><div class="gmail_quote">On Thu, May 18, 2017 at 9:15 AM, Hongbin Zheng via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I am wondering how I can tell whether a field of a struct is introduced by padding or not.</div><div><br></div><div>For example, if I have a struct:</div><br>struct foo1 {<br> char *p; /* 8 bytes */<br> char c; /* 1 byte<br> long x; /* 8 bytes */<br>};<div><br></div><div>clang may generate:</div><br>struct foo1 {<br> char *p; /* 8 bytes */<br> char c; /* 1 byte<br> char pad[7]; /* 7 bytes */<br> long x; /* 8 bytes */<br>};<div><br></div><div>Is there any way that I can tell the "pad" array is generated by padding?</div><div><br></div><div>Thanks a lot</div><span class="HOEnZb"><font color="#888888"><div>Hongbin</div></font></span></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div>