64 bit architectures and C/C++

Dave Scidmore daves at ex.heurikon.com
Thu May 2 07:02:27 AEST 1991


In article <6157 at trantor.harris-atd.com> mvm at jedi.UUCP (Matt Mahoney) writes:
>When I need to specify bits, I'm usually forced to make the 
>following assumptions:
>
>	char	8 bits
>	short	16 bits
>	long	32 bits
>
>since this is true on most machines.  Anything else would probably break
>a lot of code.

I'm supprised nobody has mentioned that the real solution to this kind
of portability problem is for the original programmer to use the
definitions in "types.h" that tell you how big chars, shorts, ints,
and longs are. I know that a lot of existing code does not take advantage
of the ability to use typdefs or #defines to alter the size of key
variables or adjust for numbers of bits for each, but doing so would
help prevent the kinds of portability problems mentioned. I always urge
people when writing their own code to be aware of size dependent code
and either use the existing "types.h", or make their own and use it to
make such code more portable. This won't help you when porting someone
elses machine dependant (and dare I say poorly written) code, but the next
guy who has to port your code will have an easier time of it.
--
Dave Scidmore, Heurikon Corp.
dave.scidmore at heurikon.com



More information about the Comp.lang.c mailing list