Commit 797efbd4 authored by Martin Storsjö's avatar Martin Storsjö

configure: Check if C++ headers define locale_t

In environments that lack a full locale.h implementation, the C++
headers might implement some fallbacks with the same name
(on windows, libcxx does this).

In these cases, don't provide the normal fallbacks from vlc_fixups.h
when compiling in C++ mode, but include the C++ <locale> header instead.

If <locale> provides locale_t, include the header and define
HAVE_NEWLOCALE (which skips the vlc_fixups.h version of locale_t),
but keep the vlc_fixups.h fallback for uselocale. (One could
also add another configure test for whether <locale> provides
the uselocale function.)

(libcxx doesn't provide any fallback for the uselocale function
since it isn't easily implemented with the msvcrt _locale_t objects.
The libcxx fallback locale_t objects are applied via the setlocale
function, and passed to functions that take a _locale_t parameter.)
parent 1151b5c9
......@@ -854,6 +854,18 @@ AC_CHECK_HEADERS([features.h getopt.h linux/dccp.h linux/magic.h mntent.h sys/ev
dnl MacOS
dnl Check if C++ headers define locale_t
AC_CACHE_CHECK([if C++ headers define locale_t],
AC_TRY_COMPILE([#include <locale>], [locale_t loc;],
if test "${ac_cv_cxx_locale_t}" != "no"; then
AC_DEFINE(HAVE_CXX_LOCALE_T, 1, Define to 1 if C++ headers define locale_t)
dnl LP64 and LLP64 architectures had better define ssize_t by themselves...
AH_TEMPLATE(ssize_t, [Define to `int' if <stddef.h> does not define.]) dnl ` (fix VIM syntax highlight
AC_CHECK_TYPE(ssize_t,, [
......@@ -314,6 +314,11 @@ void *aligned_alloc(size_t, size_t);
#if !defined(HAVE_NEWLOCALE) && defined(HAVE_CXX_LOCALE_T) && defined(__cplusplus)
# include <locale>
/* locale.h */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment