Date: Sat, 24 Nov 2012 16:18:33 +0900 From: Yamaya Takashi <yamayan@kbh.biglobe.ne.jp> To: Dimitry Andric <dim@FreeBSD.org> Cc: toolchain@freebsd.org Subject: Re: [patch][libc++]using some undeclared functions with -std=c++98, -std=c++03 or -ansi Message-ID: <50B074C9.6060402@kbh.biglobe.ne.jp> In-Reply-To: <50AFEA5D.2020607@FreeBSD.org> References: <50AEB0A1.3090803@kbh.biglobe.ne.jp> <50AFEA5D.2020607@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 2012/11/24 06:27, Dimitry Andric wrote:
> On 2012-11-23 00:09, Yamaya Takashi wrote:
>> With -std=c++98, -std=c++03 or -ansi, __LONG_LONG_SUPPORTED is not
>> defined.
>> So some functions((lldiv_t, )atoll, strtoll, strtoull, llabs, lldiv,
>> wcstoll, wcstoull) are undeclared.
>> But libc++ headers(cstdlib and cwchar) use them.
>
> The general idea of your patch is good, but we need to check it with
> upstream first. For example, __LONG_LONG_SUPPORTED is a FreeBSD
> specific define, so for the general case the solution might be more
> complicated.
>
__LONG_LONG_SUPPORTED is controlled by __STRICT_ANSI__ and
__cplusplus in sys/cdefs.h.
defined(__LONG_LONG_SUPPORTED) is equal to
!defined(__STRICT_ANSI__) || __cplusplus >= 201103L
with clang++.
> Note there are also other problems when compiling libc++ with -std=c++98
> and -std=c++03, such as complaints about namespacing and such. I am not
> entirely sure libc++ is fully supported yet under those restrictions. :)
>
What are complaints about namespacing?
[-- Attachment #2 --]
Index: contrib/libc++/include/cstdlib
===================================================================
--- contrib/libc++/include/cstdlib (revision 243468)
+++ contrib/libc++/include/cstdlib (working copy)
@@ -97,18 +97,26 @@
using ::size_t;
using ::div_t;
using ::ldiv_t;
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
using ::lldiv_t;
+#endif
using ::atof;
using ::atoi;
using ::atol;
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
using ::atoll;
+#endif
using ::strtod;
using ::strtof;
using ::strtold;
using ::strtol;
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
using ::strtoll;
+#endif
using ::strtoul;
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
using ::strtoull;
+#endif
using ::rand;
using ::srand;
using ::calloc;
@@ -125,10 +133,14 @@
using ::qsort;
using ::abs;
using ::labs;
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
using ::llabs;
+#endif
using ::div;
using ::ldiv;
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
using ::lldiv;
+#endif
using ::mblen;
using ::mbtowc;
using ::wctomb;
@@ -145,10 +157,14 @@
// MSVC already has the correct prototype in <stdlib.h.h> #ifdef __cplusplus
#if !defined(_MSC_VER) && !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
+#endif
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
+#endif
#endif // _MSC_VER
_LIBCPP_END_NAMESPACE_STD
Index: contrib/libc++/include/cwchar
===================================================================
--- contrib/libc++/include/cwchar (revision 243468)
+++ contrib/libc++/include/cwchar (working copy)
@@ -151,9 +151,13 @@
using ::wcstold;
#endif // _MSC_VER
using ::wcstol;
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
using ::wcstoll;
+#endif
using ::wcstoul;
+#if !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
using ::wcstoull;
+#endif
using ::wcscpy;
using ::wcsncpy;
using ::wcscat;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50B074C9.6060402>
