[cfe-dev] [PATCH] Libc++ Windows fixes

Ruben Van Boxem vanboxem.ruben at gmail.com
Wed Oct 19 09:10:56 PDT 2011


2011/10/17 Howard Hinnant <hhinnant at apple.com>

> Committed revision 142235.
>
> I modified the alignas support a little bit.  If I messed it up, let me
> know.
>

It looks okay, and compiles fine. Thanks for the continued commit support!

Hi,

Attached is a new patch for libc++ and msvc interoperability.

I added a new MSVC only support header for <limits>, and implemented it as
platform-specifically as I could/should :).
I renamed a "__value" variable to "__value_"; "__value" is a CLR (MSVC's
Managed C++) keyword, and it produces an error in non-CLR mode.
The notable changes are at the bottom of the patch file.

It gets me as far as this undecipherable error (which is in a
_LIBCPP_HAS_NO_VARIADICS section, this will not change in the near future;
MSVC 11.0 will not have variadic templates... grrrr):

M:\Development\Source\libc++\include\type_traits(1192) : error C2516:
'std::common_type<_Tp>::type' : is not a legal base class
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(1122) : see
declaration of 'std::common_type<_Tp>::type'
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(1192) : see
reference to class template instantiation
'std::__is_assignable_imp<_Tp,_Arg,__formal>' being compiled
M:\Development\Source\libc++\include\type_traits(1244) : error C2516:
'std::common_type<_Tp>::type' : is not a legal base class
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(1122) : see
declaration of 'std::common_type<_Tp>::type'
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(1244) : see
reference to class template instantiation
'std::__destructible_imp<_Tp,__formal>' being compiled
M:\Development\Source\libc++\include\type_traits(2013) : error C2516:
'std::common_type<_Tp>::type' : is not a legal base class
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(1122) : see
declaration of 'std::common_type<_Tp>::type'
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(2013) : see
reference to class template instantiation
'std::__is_constructible0_imp<__formal,_Tp>' being compiled
M:\Development\Source\libc++\include\type_traits(2021) : error C2516:
'std::common_type<_Tp>::type' : is not a legal base class
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(1122) : see
declaration of 'std::common_type<_Tp>::type'
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(2021) : see
reference to class template instantiation
'std::__is_constructible1_imp<__formal,_Tp,_A0>' being compiled
M:\Development\Source\libc++\include\type_traits(2029) : error C2516:
'std::common_type<_Tp>::type' : is not a legal base class
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(1122) : see
declaration of 'std::common_type<_Tp>::type'
        with
        [
            _Tp=
        ]
        M:\Development\Source\libc++\include\type_traits(2029) : see
reference to class template instantiation
'std::__is_constructible2_imp<__formal,_Tp,_A0,_A1>' being compiled
M:\Development\Source\libc++\include\utility(264) : error C4519: default
template arguments are only allowed on a class template
        M:\Development\Source\libc++\include\utility(352) : see reference to
class template instantiation 'std::pair<_T1,_T2>' being compiled

There's two different errors here: C2516 and C4519. I hope these aren't
insurmountable unimplemented template features. I'm sure you could shed more
light on what feature or implementation detail is being relied on here. The
second error does seem to be caused by the first.

Comments and commits welcome!

Ruben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111019/3566f4ee/attachment.html>
-------------- next part --------------
Index: include/__config
===================================================================
--- include/__config	(revision 142531)
+++ include/__config	(working copy)
@@ -88,7 +88,11 @@
 #endif
 
 #ifndef _LIBCPP_INLINE_VISIBILITY
-#define _LIBCPP_INLINE_VISIBILITY __forceinline
+# if _MSC_VER
+#  define _LIBCPP_INLINE_VISIBILITY __forceinline
+# else // MinGW GCC and Clang
+#  define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+# endif
 #endif
 
 #ifndef _LIBCPP_EXCEPTION_ABI
@@ -97,7 +101,7 @@
 
 #ifndef _LIBCPP_ALWAYS_INLINE
 # if _MSC_VER
-# define _LIBCPP_ALWAYS_INLINE __forceinline
+#  define _LIBCPP_ALWAYS_INLINE __forceinline
 # endif
 #endif
 
Index: include/support/win32/limits_win32.h
===================================================================
--- include/support/win32/limits_win32.h	(revision 0)
+++ include/support/win32/limits_win32.h	(revision 0)
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+//===--------------------- support/win32/limits_win32.h -------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
+#define _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
+
+#if !defined(_MSC_VER)
+#error "This header is MSVC specific, Clang and GCC should not include it"
+#else
+
+#include <float.h> // limit constants
+
+#define __FLT_MANT_DIG__   FLT_MANT_DIG
+#define __FLT_DIG__        FLT_DIG
+#define __FLT_RADIX__      FLT_RADIX
+#define __FLT_MIN_EXP__    FLT_MIN_EXP
+#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
+#define __FLT_MAX_EXP__    FLT_MAX_EXP
+#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
+#define __FLT_MIN__        FLT_MIN
+#define __FLT_MAX__        FLT_MAX
+#define __FLT_EPSILON__    FLT_EPSILON
+// predefined by MinGW GCC
+#define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F
+
+#define __DBL_MANT_DIG__   DBL_MANT_DIG
+#define __DBL_DIG__        DBL_DIG
+#define __DBL_RADIX__      DBL_RADIX
+#define __DBL_MIN_EXP__    DBL_MIN_EXP
+#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
+#define __DBL_MAX_EXP__    DBL_MAX_EXP
+#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
+#define __DBL_MIN__        DBL_MIN
+#define __DBL_MAX__        DBL_MAX
+#define __DBL_EPSILON__    DBL_EPSILON
+// predefined by MinGW GCC
+#define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L)
+
+#define __LDBL_MANT_DIG__   LDBL_MANT_DIG
+#define __LDBL_DIG__        LDBL_DIG
+#define __LDBL_RADIX__      LDBL_RADIX
+#define __LDBL_MIN_EXP__    LDBL_MIN_EXP
+#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
+#define __LDBL_MAX_EXP__    LDBL_MAX_EXP
+#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
+#define __LDBL_MIN__        LDBL_MIN
+#define __LDBL_MAX__        LDBL_MAX
+#define __LDBL_EPSILON__    LDBL_EPSILON
+// predefined by MinGW GCC
+#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+
+// __builtin replacements/workarounds
+#include <ymath.h> // internal MSVC header providing the needed functionality
+#define __builtin_huge_val()  HUGE_VAL
+#define __builtin_huge_valf() _FInf
+#define __builtin_huge_vall() _LInf
+#define __builtin_nan()       _Nan
+#define __builtin_nanf()      _FNan
+#define __builtin_nanl()      _LNan
+#define __builtin_nans()      _Snan
+#define __builtin_nansf()     _FSnan
+#define __builtin_nansl()     _LSnan
+
+#endif // _MSC_VER
+
+#endif // _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H


More information about the cfe-dev mailing list