int32 et al.

Doug Gwyn gwyn at smoke.brl.mil
Tue Jan 22 08:17:57 AEST 1991


In article <1991Jan21.135216.23447 at odi.com> benson at odi.com (Benson I. Margulies) writes:
>In article <14905 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) 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;

You mean typedef char int32[4]; however, that is much worse than
simply using long, because array types don't behave the same as
integral types and all sorts of havoc is likely to ensue.

>The system include files contain
>extern int blahblah (int, char *);
>I don't control that declaration. If I call blahblah with a long,
>the compiler bleats a warning.

As well it should!  Assuming that there is no useful information in
the high-order part of the long, you should simply cast it to int
when passing it to the blahblah() function; if there IS significant
information, then the blahblah() function is inappropriate anyway.

>for 
>extern int quux (int *);
>if I pass a long * I get an error, not just a warning.

Again, if sizeof(int)==sizeof(long) you can simply use a cast.
Otherwise, you need to write a bit of extra code, but that is
unavoidable.



More information about the Comp.lang.c mailing list