Re: 64bit format strings



On Tue, 2006-01-10 at 14:11 -0500, Matthias Clasen wrote:
> On 1/10/06, Stefan Westerfeld <stefan space twc de> wrote:
> 
> >
> > So the only remaining question is: does glib-2.x provide a guarantee
> > that gint64 (and similar types) work together with PRId64 (and similar
> > macros)? Then using PRId64 is a reasonable way to go.
> >
> > Let me explain the last thing:
> >
> > On a platform like Linux/AMD64 two integer types are 64bit integer
> > types, namely long and long long. These require two different format
> > strings, namely "%ld" and "%lld". Now a bad thing to do would be
> >
> >   typedef long int int64_t; /* <- <stdint.h> */
> >   typedef long long gint64; /* <- glib-2.x */
> >
> 
> From my reading of configure.in, we use the first integral type that
> is 8 bytes long,
You should be using the types from stdint.h if this header is available.
Anything else is non-portable and means asking for trouble.

Also, you should be aware that checking for fixed size-types inside of a
configure script only is applicable if you are not exporting them from a
source tree, because fixed-size types' sizes depend on compiler options
(CFLAGS), therefore are not constant, therefore can't be hardcoded into
configure script detected defines.

> looking at int, long, long long. So if long and long long are both 64bit, we'll
> pick long. Don't know if thats enough of a guarantee for you.
>  It might
> be worthwhile
> pointing this little pitfall out on gnome-i18n gnome org, so that
> translators can
> watch out for things like this.

Ralf





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