Simpler version of strtoumax module.
[bpt/emacs.git] / m4 / inttypes.m4
CommitLineData
aaa93559 1# inttypes.m4 serial 19
a8a2bb29
PE
2dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Derek Price, Bruno Haible.
8dnl Test whether <inttypes.h> is supported or must be substituted.
9
10AC_DEFUN([gl_INTTYPES_H],
11[
12 AC_REQUIRE([gl_STDINT_H])
a8a2bb29
PE
13
14 dnl Override <inttypes.h> always, so that the portability warnings work.
15 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
16 gl_CHECK_NEXT_HEADERS([inttypes.h])
17
a8a2bb29
PE
18 dnl Ensure that <stdint.h> defines the limit macros, since gnulib's
19 dnl <inttypes.h> relies on them. This macro is only needed when a
20 dnl C++ compiler is in use; it has no effect for a C compiler.
21 dnl Also be careful to define __STDC_LIMIT_MACROS only when gnulib's
22 dnl <inttypes.h> is going to be created, and to avoid redefinition warnings
23 dnl if the __STDC_LIMIT_MACROS is already defined through the CPPFLAGS.
24 AC_DEFINE([GL_TRIGGER_STDC_LIMIT_MACROS], [1],
25 [Define to make the limit macros in <stdint.h> visible.])
26 AH_VERBATIM([__STDC_LIMIT_MACROS_ZZZ],
27[/* Ensure that <stdint.h> defines the limit macros, since gnulib's
28 <inttypes.h> relies on them. */
29#if defined __cplusplus && !defined __STDC_LIMIT_MACROS && GL_TRIGGER_STDC_LIMIT_MACROS
30# define __STDC_LIMIT_MACROS 1
31#endif
32])
33
a8a2bb29
PE
34 dnl Check for declarations of anything we want to poison if the
35 dnl corresponding gnulib module is not in use.
36 gl_WARN_ON_USE_PREPARE([[#include <inttypes.h>
37 ]], [imaxabs imaxdiv strtoimax strtoumax])
38])
39
a8a2bb29
PE
40AC_DEFUN([gl_INTTYPES_MODULE_INDICATOR],
41[
42 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
43 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
44 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
45])
46
47AC_DEFUN([gl_INTTYPES_H_DEFAULTS],
48[
49 GNULIB_IMAXABS=0; AC_SUBST([GNULIB_IMAXABS])
50 GNULIB_IMAXDIV=0; AC_SUBST([GNULIB_IMAXDIV])
51 GNULIB_STRTOIMAX=0; AC_SUBST([GNULIB_STRTOIMAX])
52 GNULIB_STRTOUMAX=0; AC_SUBST([GNULIB_STRTOUMAX])
53 dnl Assume proper GNU behavior unless another module says otherwise.
54 HAVE_DECL_IMAXABS=1; AC_SUBST([HAVE_DECL_IMAXABS])
55 HAVE_DECL_IMAXDIV=1; AC_SUBST([HAVE_DECL_IMAXDIV])
56 HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX])
57 HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX])
aaa93559
PE
58 INT64_MAX_EQ_LONG_MAX='defined _LP64'; AC_SUBST([INT64_MAX_EQ_LONG_MAX])
59 PRI_MACROS_BROKEN=0; AC_SUBST([PRI_MACROS_BROKEN])
60 PRIPTR_PREFIX=__PRIPTR_PREFIX; AC_SUBST([PRIPTR_PREFIX])
61 UINT64_MAX_EQ_ULONG_MAX='defined _LP64'; AC_SUBST([UINT64_MAX_EQ_ULONG_MAX])
a8a2bb29 62])