<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
Would it be possible to have clang support the alignas inside a pragma pack directive, if the structure in question is also inside a pragma ms_struct directive?  There are some teams at Microsoft using clang to target non-Windows platforms but sharing code
 that expects MSVC structure layout.  Using the Microsoft C++ ABI isn’t feasible as the platform in question is not a Microsoft Windows platform.  
<div><br>
</div>
<div>Thanks,</div>
<div>Schwieb</div>
<div>Microsoft Mac Team<br>
<div><br>
<div>
<div>On Jul 23, 2014, at 9:48 AM, jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<div><br class="Apple-interchange-newline">
On Jul 23, 2014, at 9:45 AM, jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<br>
<div>
<div>On Jul 22, 2014, at 5:26 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote"><br>
<div><br>
</div>
<div>Presumably they handle alignas the same way they handle __declspec(align(N)), which overrides packing.  MSVC appears to have two notions of alignment, required and advisory, while the C++ standard, Clang, and GCC only have one.  One way to observe this
 is to see that they will align an int64 to 8 bytes in a struct, but they will not realign the stack to 8 bytes when that struct is stack allocated.</div>
<div><br>
</div>
<div>Also, Clang does respect alignas in this case when targeting the Microsoft C++ ABI.</div>
</div>
</div>
</div>
</blockquote>
<br>
</div>
<div>I tried the test case with these options for MS ABI:</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">clang -cc1 -triple x86_64-windows-msvc -std=c++11 -S t.cpp</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">Assembly indicates that it does not seem to respect alignas. Should I be using other options?</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
<div style="margin: 0px;">main:</div>
<div style="margin: 0px;"><span class="Apple-tab-span" style="white-space: pre;"></span>movl<span class="Apple-tab-span" style="white-space: pre;">
</span>$28, %eax</div>
<div style="margin: 0px;"><span class="Apple-tab-span" style="white-space: pre;"></span>movl<span class="Apple-tab-span" style="white-space: pre;">
</span>$0, -4(%rsp)</div>
<div style="margin: 0px;"><span class="Apple-tab-span" style="white-space: pre;"></span>retq</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
Oops. I was using an old clang. Sorry for the noise.</div>
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<br>
</div>
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">main:</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space: pre;"></span>movl<span class="Apple-tab-span" style="white-space: pre;">
</span>$64, %eax</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space: pre;"></span>retq</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<blockquote type="cite">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
<div>- Fariborz</div>
<div><br>
</div>
</div>
</div>
<br>
</div>
</blockquote>
</div>
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">cfe-dev
 mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<a href="mailto:cfe-dev@cs.uiuc.edu" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">cfe-dev@cs.uiuc.edu</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></blockquote>
</div>
<br>
</div>
</div>
</body>
</html>