[libc-commits] [PATCH] D134676: [libc][windows] fix small build issues.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Sep 26 21:57:49 PDT 2022


sivachandra added inline comments.


================
Comment at: libc/src/__support/FPUtil/x86_64/FEnvImpl.h:57
   static constexpr uint16_t DIV_BY_ZERO = 0x4;
-  static constexpr uint16_t OVERFLOW = 0x8;
-  static constexpr uint16_t UNDERFLOW = 0x10;
----------------
lntue wrote:
> michaelrj wrote:
> > lntue wrote:
> > > michaelrj wrote:
> > > > sivachandra wrote:
> > > > > lntue wrote:
> > > > > > Can you also change other exception flags to the same format too?
> > > > > Where is the macro named `OVERFLOW` coming from?
> > > > here's the error:
> > > > ```
> > > > In file included from C:/src/llvm-project/libc\src/__support/FPUtil/FEnvImpl.h:21:
> > > > C:/src/llvm-project/libc\src/__support/FPUtil/x86_64/FEnvImpl.h(271,44): error: expected unqualified-id
> > > >     raise_helper(internal::ExceptionFlags::OVERFLOW);
> > > >                                            ^
> > > > C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(965,25): note: expanded from macro 'OVERFLOW'
> > > >     #define OVERFLOW    _OVERFLOW
> > > >                         ^
> > > > C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(68,21): note: expanded from macro '_OVERFLOW'
> > > > #define _OVERFLOW   3   // overflow range error
> > > > ```
> > > > If I had to guess it's coming in through `#include <fenv.h>`
> > > Look like that definition is guarded by `_CRT_INTERNAL_NONSTDC_NAMES` (https://github.com/tpn/winsdk-10/blob/master/Include/10.0.16299.0/ucrt/corecrt_math.h#L962) internally to Windows C runtimes?  Either `#undef` this or adding some Windows specific build flag might be another solution?
> > `#undef OVERFLOW` does work, but that feels like a dangerous solution
> What I meant is to detect if `_CRT_INTERNAL_NONSTDC_NAMES` is defined then `#undef _CRT_INTERNAL_NONSTDC_NAMES` before including <fenv.h> and maybe redefine it after for Windows.
I thought these macros stay undefined when compiling with clang-cl. Does something from here help: https://clang.llvm.org/docs/MSVCCompatibility.html


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134676/new/

https://reviews.llvm.org/D134676



More information about the libc-commits mailing list