Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!lll-winken!lll-lcc!ames!mailrus!purdue!decwrl!labrea!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: 64 bit ints Message-ID: <608@quintus.UUCP> Date: 31 Oct 88 08:05:42 GMT Article-I.D.: quintus.608 References: <6264@june.cs.washington.edu> <225800084@uxe.cso.uiuc.edu> <8803@smoke.BRL.MIL> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 30 In article <8803@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <225800084@uxe.cso.uiuc.edu> mcdonald@uxe.cso.uiuc.edu writes: >-Then allow the user to specify, either ... by command line switches ... >-whatever combination of shorts, ints and longs he wants >This is unworkable. The application code has to interface with the >C library and other libraries. It is unrealistic to expect there to >be umpteen variants of each library to support all the permutations >of data sizes. It may be unworkable, but there are a lot of Fortran compilers that do it. (UNIX "f77" compilers use the flags "-i2" (int=short) "-i4" (int=long).) What you do is introduce some implementation-specific types: __s8 __s16 __s32 __s64 (signed) __u8 __u16 __u32 __u64 (unsigned) 8-bit 16-bit 32-bit 64-bit Then the library headers include prototypes using the implementation- specific types. The *printf family can be handled by ensuring that integral arguments passed to that function are widened to __s8 or __u8 or whatever. The *scanf family is tricky, but I can think of several solutions. While it would be workable, it probably wouldn't be a good idea. Probably the best thing to do would be to pick an "efficient" value for 'int', and offer two system-dependent macros _SIGNED(N), _UNSIGNED(N) expanding to the smallest integral types capable of holding N-bit integers; the expansions needn't be available any other way. _SIGNED(N) is similar to a current proposal for Fortran 8X, and the concept is sufficiently system-independent that other compiler-writers might pick it up.