[vlc-devel] [PATCH] configure: Check if C++ headers define locale_t

Hugo Beauzée-Luyssen hugo at beauzee.fr
Wed Feb 28 21:31:48 CET 2018


> On 28 Feb 2018, at 21:23, Martin Storsjö <martin at martin.st> wrote:
> 
> On Wed, 28 Feb 2018, Martin Storsjö wrote:
> 
>> On Wed, 28 Feb 2018, Martin Storsjö wrote:
>> 
>>> 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.)
>>> ---
>>> configure.ac         | 12 ++++++++++++
>>> include/vlc_fixups.h |  5 +++++
>>> 2 files changed, 17 insertions(+)
>>> diff --git a/configure.ac b/configure.ac
>>> index c03533e..0faeef9 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 0bd8442..533cff1 100644
>>> --- a/include/vlc_fixups.h
>>> +++ b/include/vlc_fixups.h
>>> @@ -314,6 +314,11 @@ void *aligned_alloc(size_t, size_t);
>>> # define HAVE_USELOCALE
>>> #endif
>>> +#if !defined(HAVE_USELOCALE) && defined(HAVE_CXX_LOCALE_T) && defined(__cplusplus)
>>> +# include <locale>
>>> +# define HAVE_NEWLOCALE
>> 
>> Locally amended the check above to check !defined(HAVE_NEWLOCALE) instead, for consistency.
> 
> And pushed. Now the current git master should be buildable with llvm-mingw for i686 and x86_64 without any out-of-tree patches.

\o/
I’ll try to setup a buildbot for that sometime soon! Thanks a lot for your work :)


More information about the vlc-devel mailing list