Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!wuarchive!uunet!odi!benson From: benson@odi.com (Benson I. Margulies) Newsgroups: comp.lang.c Subject: Re: int32 et al. Message-ID: <1991Jan22.175900.24941@odi.com> Date: 22 Jan 91 17:59:00 GMT References: <26@christmas.UUCP> <867@TALOS.UUCP> <1991Jan19.185101.27554@odi.com> <14905@smoke.brl.mil> <1991Jan21.135216.23447@odi.com> <1991Jan22.023844.29849@dirtydog.ima.isc.com> Reply-To: benson@odi.com (Benson I. Margulies) Organization: Object Design Inc., Burlington, MA Lines: 54 In article <1991Jan22.023844.29849@dirtydog.ima.isc.com> karl@ima.isc.com (Karl Heuer) writes: >In article <1991Jan21.135216.23447@odi.com> benson@odi.com (Benson I. Margulies) writes: >>>>If we used int for a 32 byte int, we are nailed on the PCs. If we use >>>>long, C++ compilers tend to moan piteously about [type clash] >> >>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. > >How does int32 help, then? You said you define int32 as long on some machines >(PCs), so passing an int32 to this function is just wrong. Looks to me as >though you need to cast% it to int, regardless of whether you're using int32 >or long. > >>for >> extern int quux (int *); >>if I pass a long * I get an error, not just a warning. >>So I can't just use long all the time unless I type in all my >>own system function prototypes. > >And here, it's worse. If you fake it with a cast or by writing a fake >prototype, you're likely to get the wrong answer, on machines where int and >long have different sizes. Again, I see no advantage of int32 over long. > I'm concerned, at the instant, with precisely three machines: machine int long size_t int32 --------------------------------------------------------------------- sun et. al. 32 32 int int PC 16 32 long long RS/6000 32 32 unsigned long long This works a lot better than using long. 1) when I need to specify the layout for data that is stored on disk or transported across the net, and I want 32 bits, just like in a TCP packet, I say "int32." 2) when I go to pass a value to a system routine that takes an "int" on the sun, I don't get whining and complaining about passing a long to an int. If I said "int" case (1) would break on the PC. If I said "long" I'd get warnings on the sun. And some things are really just integers, they don't have any abstract nature at all. If I have to deal with 36 or 24 or whatever, I'll have a harder problem to hack. No question. -- Benson I. Margulies