Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: C machine Message-ID: <6927@brl-smoke.ARPA> Date: 6 Jan 88 01:20:50 GMT References: <7535@alice.UUCP> <8226@steinmetz.steinmetz.UUCP> <461@auvax.UUCP> <163@bhjat.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 41 In article <163@bhjat.UUCP> bhj@bhjat.UUCP (Burt Janz) writes: >In the "white book" on page 34, there is a brief discussion of "..."natural" >size for a particular machine...". I assume that means the internal register >word size, not the bus transfer word size. Not necessarily, although usually it's the register size (on a general register architecture) or the memory word size (on most other common machines). The implementor is free to make some really weird choice, so long as the language constraints are met. >I hold that a short is defined as ALWAYS being 16 bits, and a long as >ALWAYS being 32 bits. Since you have K&R, presumably you can check the table on p.34 to see that it contradicts you. >So, on a 64-bit processor, what's an int? On our Crays, it's 64 bits, naturally. (So's a short!) I have heard of at least one 64-bit machine where int was 32 bits, or at least that size was seriously considered. I don't think that's in keeping with the intent of "int", but it would be legal. The size-related things you may portably rely on (except on perhaps a few non-ANSI conforming implementations, typically "toy compilers") are: 1 == sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) sizeof(float) <= sizeof(double) <= sizeof(long double) sizeof(void *) == sizeof(char *) >= sizeof(any_other_object_type *) BITS(char) >= 8 where BITS is assumed to be a macro that returns the number of bits in an object of that type BITS(short) >= 16 BITS(int) >= 16 BITS(long) >= 32 BITS(float) >= 24 BITS(double) >= 38 BITS(long double) >= 38 BITS(void *) >= 15 BITS(char *) >= 15 BITS(any_other_object_type *) >= 14 "signed" and "unsigned" objects have the same size