[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] integer size
From: |
Werner LEMBERG |
Subject: |
Re: [Groff] integer size |
Date: |
Wed, 31 Oct 2001 00:28:32 +0100 (CET) |
> But it is not cleanly programmed. It depends on the quite arbitrary
> behavior of the GNU utilities to have the int types 32 bits, while
> ANSI garantees only long to have that length.
groff had always int = 32bit in mind, from the very beginning.
> I use the following clutch to optimize memory usage.
>
> # define INTEGER_LENGTH (32 / 8)
> # if sizeof(int) >= INTEGER_LENGTH
> typedef int Integer;
> # else
> typedef long int Integer;
> # endif
This doesn't work, as Larry has told you. In the FreeType library
(which cleanly compiles on 16, 32, and 64bit platforms), we use the
following in `ANSI' mode (i.e., without using a configure script to
test for the width of the int type):
/* We use <limits.h> values to know the sizes of the types. */
#include <limits.h>
/* The number of bytes in an `int' type. */
#if UINT_MAX == 0xFFFFFFFFUL
#define FT_SIZEOF_INT 4
#elif UINT_MAX == 0xFFFFU
#define FT_SIZEOF_INT 2
#elif UINT_MAX > 0xFFFFFFFFU && UINT_MAX == 0xFFFFFFFFFFFFFFFFU
#define FT_SIZEOF_INT 8
#else
#error "Unsupported number of bytes in `int' type!"
#endif
/* The number of bytes in a `long' type. */
#if ULONG_MAX == 0xFFFFFFFFUL
#define FT_SIZEOF_LONG 4
#elif ULONG_MAX > 0xFFFFFFFFU && ULONG_MAX == 0xFFFFFFFFFFFFFFFFU
#define FT_SIZEOF_LONG 8
#else
#error "Unsupported number of bytes in `long' type!"
#endif
The code goes on rather lengthy to typedef the various integer types
in dependency on those macros.
To be honest, I don't want such code in groff. Maybe this decision
limits the available platforms groff can be used on, but it makes life
simpler. Another argument: Until now, there was not a single
complaint or bug report regarding this issue.
> BTW, I finished the libdriver/input.cc file. Do you need it
> urgently, or are there some more days left for polishing?
I won't start work before next week.
Werner
Re: [Groff] integer size, Werner LEMBERG, 2001/10/30