It is vital that config.h be included before gmp.h in order to get the right expansions for __GMP_PUBLIC_FULL and __GMP_PUBLIC_DEFINE, once we start declaring hidden symbols.
Ease the burden of include orderings by always using only "gmp-impl.h", and getting everything else -- including system includes -- from there. --- gmp-impl.h | 62 +++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/gmp-impl.h b/gmp-impl.h index 7ebfe4d..2f5d75e 100644 --- a/gmp-impl.h +++ b/gmp-impl.h @@ -34,8 +34,14 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #ifndef __GMP_IMPL_H__ #define __GMP_IMPL_H__ +/* We never include gmp-impl.h from configure. We do re-use the define + __GMP_WITHIN_CONFIGURE during BUILT_SOURCES to avoid including several + files below that may not yet be built. */ +#include "config.h" +#define _GNU_SOURCE 1 + #if defined _CRAY -#include <intrinsics.h> /* for _popcnt */ +# include <intrinsics.h> /* for _popcnt */ #endif /* limits.h is not used in general, since it's an ANSI-ism, and since on @@ -49,9 +55,44 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ short can be 24, 32, 46 or 64 bits, and different for ushort. */ #if defined _CRAY -#include <limits.h> +# include <limits.h> +#endif + +#if HAVE_INTTYPES_H /* for uint_least32_t */ +# include <inttypes.h> +#else +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#endif +#if HAVE_FLOAT_H +# include <float.h> /* for DBL_MAX_10_EXP etc */ +#endif +#if HAVE_SYS_TYPES_H +# include <sys/types.h> /* for quad_t */ +#endif +#if HAVE_STDARG +# include <stdarg.h> /* for va_list and hence doprnt_funs_t */ +#else +# include <varargs.h> #endif +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stddef.h> +#include <ctype.h> + +#if HAVE_OBSTACK_VPRINTF +# include <obstack.h> +#endif + +#ifdef __cplusplus +# include <string> /* for std::string */ +#endif + +#include "gmp.h" + #ifndef __MPN #define __MPN(x) __gmpn_##x #endif @@ -178,7 +219,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ DECL_addmul_1 (name) #if ! defined (__GMP_WITHIN_CONFIGURE) -#include "config.h" #include "gmp-mparam.h" #include "fib_table.h" #include "fac_table.h" @@ -188,20 +228,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #endif #endif -#if HAVE_INTTYPES_H /* for uint_least32_t */ -# include <inttypes.h> -#else -# if HAVE_STDINT_H -# include <stdint.h> -# endif -#endif - -#ifdef __cplusplus -#include <cstring> /* for strlen */ -#include <string> /* for std::string */ -#endif - - #ifndef WANT_TMP_DEBUG /* for TMP_ALLOC_LIMBS_2 and others */ #define WANT_TMP_DEBUG 0 #endif @@ -3734,6 +3760,8 @@ typedef mp_limb_t UWtype; typedef unsigned int UHWtype; #define W_TYPE_SIZE GMP_LIMB_BITS +#include "longlong.h" + /* Define ieee_double_extract and _GMP_IEEE_FLOATS. Bit field packing is "implementation defined" according to C99, which -- 1.8.1.2 _______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org http://gmplib.org/mailman/listinfo/gmp-devel