/* Test of <stdint.h> substitute.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006-2010 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2006. */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <config.h>
/* Whether to enable pedantic checks. */
#define DO_PEDANTIC 0
#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
+#define __STDC_CONSTANT_MACROS 1 /* likewise */
#include <stdint.h>
#include "verify.h"
# define _verify_func(line) _verify_func2(line)
# define _verify_func2(line) verify_func_ ## line
#else
-# define verify_same_types(expr1,expr2)
+# define verify_same_types(expr1,expr2) extern void verify_func (int)
#endif
/* 7.18.1.1. Exact-width integer types */
verify_same_types (INT32_MIN, (int32_t) 0 + 0);
verify_same_types (INT32_MAX, (int32_t) 0 + 0);
-#if HAVE_INT64_T_IN_STDINT_H || _STDINT_H_HAVE_INT64
+#ifdef INT64_MAX
int64_t a4[3] = { INT64_C (17), INT64_MIN, INT64_MAX };
verify (TYPE_MINIMUM (int64_t) == INT64_MIN);
verify (TYPE_MAXIMUM (int64_t) == INT64_MAX);
verify (TYPE_MAXIMUM (uint32_t) == UINT32_MAX);
verify_same_types (UINT32_MAX, (uint32_t) 0 + 0);
-#if HAVE_UINT64_T_IN_STDINT_H || _STDINT_H_HAVE_UINT64
+#ifdef UINT64_MAX
uint64_t b4[2] = { UINT64_C (17), UINT64_MAX };
verify (TYPE_MAXIMUM (uint64_t) == UINT64_MAX);
verify_same_types (UINT64_MAX, (uint64_t) 0 + 0);
verify_same_types (INT_LEAST32_MIN, (int_least32_t) 0 + 0);
verify_same_types (INT_LEAST32_MAX, (int_least32_t) 0 + 0);
-#if HAVE_INT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_INT64
+#ifdef INT_LEAST64_MAX
int_least64_t c4[3] = { 17, INT_LEAST64_MIN, INT_LEAST64_MAX };
verify (TYPE_MINIMUM (int_least64_t) == INT_LEAST64_MIN);
verify (TYPE_MAXIMUM (int_least64_t) == INT_LEAST64_MAX);
verify (TYPE_MAXIMUM (uint_least32_t) == UINT_LEAST32_MAX);
verify_same_types (UINT_LEAST32_MAX, (uint_least32_t) 0 + 0);
-#if HAVE_UINT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_UINT64
+#ifdef UINT_LEAST64_MAX
uint_least64_t d4[2] = { 17, UINT_LEAST64_MAX };
verify (TYPE_MAXIMUM (uint_least64_t) == UINT_LEAST64_MAX);
verify_same_types (UINT_LEAST64_MAX, (uint_least64_t) 0 + 0);
verify_same_types (INT_FAST32_MIN, (int_fast32_t) 0 + 0);
verify_same_types (INT_FAST32_MAX, (int_fast32_t) 0 + 0);
-#if HAVE_INT_FAST64_T_IN_STDINT_H || _STDINT_H_HAVE_INT64
+#ifdef INT_FAST64_MAX
int_fast64_t e4[3] = { 17, INT_FAST64_MIN, INT_FAST64_MAX };
verify (TYPE_MINIMUM (int_fast64_t) == INT_FAST64_MIN);
verify (TYPE_MAXIMUM (int_fast64_t) == INT_FAST64_MAX);
verify (TYPE_MAXIMUM (uint_fast32_t) == UINT_FAST32_MAX);
verify_same_types (UINT_FAST32_MAX, (uint_fast32_t) 0 + 0);
-#if HAVE_UINT_FAST64_T_IN_STDINT_H || _STDINT_H_HAVE_UINT64
+#ifdef UINT_FAST64_MAX
uint_fast64_t f4[2] = { 17, UINT_FAST64_MAX };
verify (TYPE_MAXIMUM (uint_fast64_t) == UINT_FAST64_MAX);
verify_same_types (UINT_FAST64_MAX, (uint_fast64_t) 0 + 0);
verify (TYPE_MAXIMUM (uintmax_t) == UINTMAX_MAX);
verify_same_types (UINTMAX_MAX, (uintmax_t) 0 + 0);
+/* As of 2007, Sun C and HP-UX 10.20 cc don't support 'long long' constants in
+ the preprocessor. */
+#if !(defined __SUNPRO_C || (defined __hpux && !defined __GNUC__))
#if INTMAX_MIN && INTMAX_MAX && UINTMAX_MAX
/* ok */
#else
err or;
#endif
+#endif
/* 7.18.3. Limits of other integer types */
err or;
#endif
+#if HAVE_WCHAR_T
verify (TYPE_MINIMUM (wchar_t) == WCHAR_MIN);
verify (TYPE_MAXIMUM (wchar_t) == WCHAR_MAX);
verify_same_types (WCHAR_MIN, (wchar_t) 0 + 0);
verify_same_types (WCHAR_MAX, (wchar_t) 0 + 0);
-#if WCHAR_MIN != 17 && WCHAR_MAX
+# if WCHAR_MIN != 17 && WCHAR_MAX
/* ok */
-#else
+# else
err or;
+# endif
#endif
-#include <stdio.h>
-#include <time.h>
-#include <wchar.h>
+#if HAVE_WINT_T
+# include <wchar.h>
verify (TYPE_MINIMUM (wint_t) == WINT_MIN);
verify (TYPE_MAXIMUM (wint_t) == WINT_MAX);
verify_same_types (WINT_MIN, (wint_t) 0 + 0);
verify_same_types (WINT_MAX, (wint_t) 0 + 0);
-#if WINT_MIN != 17 && WINT_MAX
+# if WINT_MIN != 17 && WINT_MAX
/* ok */
-#else
+# else
err or;
+# endif
#endif
/* 7.18.4. Macros for integer constants */
verify (UINT32_C (17) == 17);
verify_same_types (UINT32_C (17), (uint_least32_t)0 + 0);
-#if HAVE_INT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_INT64
+#ifdef INT64_C
verify (INT64_C (17) == 17);
verify_same_types (INT64_C (17), (int_least64_t)0 + 0);
#endif
-#if HAVE_UINT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_UINT64
+#ifdef UINT64_C
verify (UINT64_C (17) == 17);
verify_same_types (UINT64_C (17), (uint_least64_t)0 + 0);
#endif
int
-main ()
+main (void)
{
return 0;
}