int32 et al.

Jim Mercer merce at iguana.uucp
Thu Jan 24 14:15:42 AEST 1991


In article <1991Jan23.120327.17759 at watmath.waterloo.edu> datangua at watmath.waterloo.edu (David Tanguay) writes:
>In article <1991Jan21.135216.23447 at odi.com> benson at odi.com (Benson I. Margulies) writes:
>|>But you didn't address the problems I pointed out, for example the
>|>complete lack of ANY type whose size if precisely 32 bits in some
>|>implementations.
>|Well, if we ever hit such a beast, there's always
>|typedef char [4] int32;
>
>Which still isn't (necessarily) 32 bits. There is no guarantee that a char
>is exactly 8 bits (36 bit machines use 9 bit chars, and I wouldn't be
>surprised to see a 16 bit char on a 16 bit word machine like the
>Honeywell DPS-6).

[ i'm just jumping into this thread, so please forgive me if this was already
  said ]

could the problem be resolved as such:

[defs.h] (or some similar file)

/* define the type which is 8 bits on your system */

#define BITS8	char
/* #define BITS8	int */
/* #define BITS8	some_other_type */


[sample.c]

...

BITS8	bits8;
BITS16	bits16[2];
BITS32	bits32[4];

this could also be done with typedefs i guess.  (i don't use them much)

this also assumes your system has an 8 bit type.

-- 
[ Jim Mercer   work: jim at lsuc.on.ca  home: merce at iguana.uucp  +1 519 570-3467 ]
[                "Clickity-Click, Barba-Trick" - The Barbapapas               ]



More information about the Comp.lang.c mailing list