[vlc-commits] configure: Check if C++ headers define locale_t
Martin Storsjö
git at videolan.org
Fri Nov 23 16:11:04 CET 2018
vlc/vlc-3.0 | branch: master | Martin Storsjö <martin at martin.st> | Wed Feb 28 11:59:55 2018 +0200| [7a2c77128e058331f675d154dc7dd9f3296a08ed] | committer: Hugo Beauzée-Luyssen
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.)
(cherry picked from commit 797efbd40743251090d4cfa1db176b2317291507)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=7a2c77128e058331f675d154dc7dd9f3296a08ed
---
configure.ac | 12 ++++++++++++
include/vlc_fixups.h | 5 +++++
2 files changed, 17 insertions(+)
diff --git a/configure.ac b/configure.ac
index 00c66b2054..a6ff64595e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -854,6 +854,18 @@ AC_CHECK_HEADERS([features.h getopt.h linux/dccp.h linux/magic.h mntent.h sys/ev
dnl MacOS
AC_CHECK_HEADERS([xlocale.h])
+dnl Check if C++ headers define locale_t
+AC_LANG_PUSH(C++)
+AC_CACHE_CHECK([if C++ headers define locale_t],
+ [ac_cv_cxx_locale_t],
+ [ac_cv_cxx_locale_t=no
+ AC_TRY_COMPILE([#include <locale>], [locale_t loc;],
+ [ac_cv_cxx_locale_t=yes])])
+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)
+fi
+AC_LANG_POP(C++)
+
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,, [
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index 6c0de2854b..239cad4d77 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -318,6 +318,11 @@ void *aligned_alloc(size_t, size_t);
# define HAVE_USELOCALE
#endif
+#if !defined(HAVE_NEWLOCALE) && defined(HAVE_CXX_LOCALE_T) && defined(__cplusplus)
+# include <locale>
+# define HAVE_NEWLOCALE
+#endif
+
/* locale.h */
#ifndef HAVE_USELOCALE
# ifndef HAVE_NEWLOCALE
More information about the vlc-commits
mailing list