<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 21, 2016 at 10:40 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Wed, Dec 21, 2016 at 2:18 PM, Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br>
> Adding more appropriate email address for Andrey.<br>
><br>
> On Wed, Dec 21, 2016 at 11:17 AM Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br>
>><br>
>> I can't really reproduce Andrey's original problem (_byteswap_ushort<br>
>> compiles for me just fine without this include), but if I change this to<br>
>> <cstdlib> then I assume I have to change _byteswap_ushort to<br>
>> std::_byteswap_ushort, and yet that fails.  So I'm not really sure<br></span></blockquote><div>The problem was found when my <span style="color:rgb(84,84,84)">colleague</span> compiled LLVM with our experimental</div><div>version of libc++ on Windows which has different include dependencies compared to</div><div>Microsoft STL.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
<br>
</span>You shouldn't have to use std::_byteswap_ushort by including cstdlib;<br>
it includes stdlib.h directly (without wrapping anything in namespace<br>
std) and only introduces standard function names into namespace std.<br>
However, it's purely a cosmetic request as the end results should be<br>
identical.<br></blockquote><div>The standard doesn't specify whether cstdlib includes stdlib.h or stdlib.h includes cstdlib.</div><div>And the problems do arise in practice - libstdc++ and libc++ chose different approaches</div><div>for cmath/math.h pair. But _byteswap_ushort is not in the standard anyway and Microsoft</div><div>can do whatever it wants so it is best to follow MSDN documentation.</div><div><br></div><div>-- Andrey Khalyavin</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="gmail-HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span><div class="gmail-HOEnZb"><div class="gmail-h5"><br>
>><br>
>>> > --- llvm/trunk/include/llvm/<wbr>Support/SwapByteOrder.h (original)<br>
>>> > +++ llvm/trunk/include/llvm/<wbr>Support/SwapByteOrder.h Wed Dec 21 12:50:52<br>
>>> > 2016<br>
>>> > @@ -18,6 +18,9 @@<br>
>>> >  #include "llvm/Support/Compiler.h"<br>
>>> >  #include "llvm/Support/DataTypes.h"<br>
>>> >  #include <cstddef><br>
>>> > +#if defined(_MSC_VER) && !defined(_DEBUG)<br>
>>> > +#include <stdlib.h><br>
>>><br>
>>> <cstdlib> instead of <stdlib.h>?<br>
>>><br>
>>> ~Aaron<br>
</div></div></blockquote></div><br></div></div>