autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting a 64 bit integer type


From: Paul Eggert
Subject: Re: getting a 64 bit integer type
Date: Sun, 15 Jul 2001 22:34:00 -0700 (PDT)

> From: Dale E Martin <address@hidden>
> Date: Thu, 5 Jul 2001 14:21:36 -0400
>
> Would it make sense for autoconf to have a macro to define all of
> the available native types for the language it supports?  Or is this
> a fairly unique bit of information to require?

In C99, the "right" way to see whether you have a 64-bit type is like
this:

   #include <stdint.h>

   #ifdef INT64_MAX
    /* There is a type int64_t.  */
   #else
    /* There is no such type, but 'long long' is longer than 64-bit.  */
   #endif

You can also include <inttypes.h> instead of <stdint.h>; this tends to
work better in practice with pre-C99 hosts, but <inttypes.h> drags in
more stuff and C99 does not require it for standalone compilers.

It might be nice to autoconfize this somehow, so that your source code
would look like this:

   #if HAVE_CONFIG_H
   # include <config.h> /* define INT64_MAX, int64_t, etc. if needed */
   #endif

   #if HAVE_INTTYPES_H
   # include <inttypes.h>
   #else
   # if HAVE_STDINT_H
   #  include <stdint.h>
   # endif
   #endif

   #ifdef INT64_MAX
    /* There is a type int64_t.  */
   #else
    /* There is no such type, but 'long long' is longer than 64-bit.  */
   #endif

That shouldn't take too much work -- perhaps you'd like to take a stab
at an autoconf macro to do that?

There is no easy way in C99 to iterate through all the integer type
widths.  I don't offhand see how to solve that problem
straightforwardly with autoconf, unfortunately.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]