Index: include/__bsd_locale_fallbacks.h =================================================================== --- include/__bsd_locale_fallbacks.h +++ include/__bsd_locale_fallbacks.h @@ -118,7 +118,26 @@ va_list __va; va_start(__va, __format); __locale_raii __current( uselocale(__l), uselocale ); +#if _LIBCPP_HAS_NO_ASPRINTF + va_list __va2; + va_copy(__va2, __va); + int __res = vsnprintf(0, 0, __format, __va2); + va_end(__va2); + if(__res < 0) + { + va_end(__va); + return __res; + } + *__s = (char *)malloc(__res+1); + if(*__s == 0) + { + va_end(__va); + return -1; + } + vsnprintf(*__s, __res+1, __format, __va); +#else int __res = vasprintf(__s, __format, __va); +#endif va_end(__va); return __res; } Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -871,6 +871,10 @@ #endif #endif +#if defined(_NEWLIB_VERSION) +#define _LIBCPP_HAS_NO_ASPRINTF 1 +#endif + #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 #endif