[llvm] r290263 - Add missing includes on Windows.

Andrey Khalyavin via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 21 12:17:01 PST 2016


On Wed, Dec 21, 2016 at 10:40 PM, Aaron Ballman <aaron at aaronballman.com>
wrote:

> On Wed, Dec 21, 2016 at 2:18 PM, Zachary Turner <zturner at google.com>
> wrote:
> > Adding more appropriate email address for Andrey.
> >
> > On Wed, Dec 21, 2016 at 11:17 AM Zachary Turner <zturner at google.com>
> wrote:
> >>
> >> I can't really reproduce Andrey's original problem (_byteswap_ushort
> >> compiles for me just fine without this include), but if I change this to
> >> <cstdlib> then I assume I have to change _byteswap_ushort to
> >> std::_byteswap_ushort, and yet that fails.  So I'm not really sure
>
The problem was found when my colleague compiled LLVM with our experimental
version of libc++ on Windows which has different include dependencies
compared to
Microsoft STL.

>
> You shouldn't have to use std::_byteswap_ushort by including cstdlib;
> it includes stdlib.h directly (without wrapping anything in namespace
> std) and only introduces standard function names into namespace std.
> However, it's purely a cosmetic request as the end results should be
> identical.
>
The standard doesn't specify whether cstdlib includes stdlib.h or stdlib.h
includes cstdlib.
And the problems do arise in practice - libstdc++ and libc++ chose
different approaches
for cmath/math.h pair. But _byteswap_ushort is not in the standard anyway
and Microsoft
can do whatever it wants so it is best to follow MSDN documentation.

-- Andrey Khalyavin


>
> ~Aaron
>
> >>
> >>> > --- llvm/trunk/include/llvm/Support/SwapByteOrder.h (original)
> >>> > +++ llvm/trunk/include/llvm/Support/SwapByteOrder.h Wed Dec 21
> 12:50:52
> >>> > 2016
> >>> > @@ -18,6 +18,9 @@
> >>> >  #include "llvm/Support/Compiler.h"
> >>> >  #include "llvm/Support/DataTypes.h"
> >>> >  #include <cstddef>
> >>> > +#if defined(_MSC_VER) && !defined(_DEBUG)
> >>> > +#include <stdlib.h>
> >>>
> >>> <cstdlib> instead of <stdlib.h>?
> >>>
> >>> ~Aaron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161221/79f615c6/attachment.html>


More information about the llvm-commits mailing list