Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Something C might need Date: Fri, 22 Sep 2017 15:24:29 -0700 Organization: None to speak of Lines: 31 Message-ID: References: <1cc86992-d71e-42b9-818f-f883b78e79ce@googlegroups.com> <7ac3b44a-b838-4462-88c8-adcd77d61ce1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="04a59581cee8bc27b4414e17aac7cecf"; logging-data="18513"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UqWc/c6OY8TSS0YUUhtH3" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:w8k22rHAf4yfQycFNqJSFpsHdGE= sha1:K2e5j03KLwBpN5w8XDCi9eu82fE= Xref: csiph.com comp.lang.c:120165 Richard Damon writes: [...] > When C started, then 'normal' sizes (normal != required, but typical for > mainstream processors) was char=8b, short=16b, int=16b, long=32b, as the > most common processors had 16 bit primary registers (and these sizes are > reflected in the minimum allowed ranges for the types). These machines > were typically called 16 bit processors. K&R1, published in 1978, shows systems with 16-bit, 32-bit, and 36-bit int. [...] > Moving to 64 bits gives us an issue even bigger than before. Registers > ARE 64 bits, and we get natural arithmetic module 2^64, so ideally, int > would move to 64 bits, but then we run out of standard names for the > smaller types, having 3 sizes 8, 16, 32 but only two names char, short. > Because of this, some just keep int being 32 bits. (Some have proposed > that we need to add a type 'long short' to be the 32 bit type, or make > short be 32 bits and have a 'short short' type for 16 bits. My suggestion, requiring no changes to the language, would be to define extended integer types for the intermediate sizes, and then define [u]intN_t in terms of those types. That way if you specifically want 32 bits you can use int32_t (or int_fast32_t, or int_least32_t). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"