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: sizeof Data types Date: Thu, 11 Aug 2016 12:04:18 -0700 Organization: None to speak of Lines: 31 Message-ID: References: <4ccb69e9-3af1-4bf7-8893-773508c03bf9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="23275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ka2JJ6/M0f2hcm4EpyE9v" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:FS8vGped90jbvd4U6PgursmWyVw= sha1:JBYDbOD/HePdFUImFN78B1REDmA= Xref: csiph.com comp.lang.c:92141 Philip Lantz writes: > jameskuyper@verizon.net wrote: >> > If you need to have confidence as to how big exactly short, int, long or >> > long long are, use instead the types specified in stdint.h: int32_t, >> > uint16_t etc. >> >> "If you need to have confidence as to exactly how big" one of the >> standard types is, you should use sizeof find out. I think you mean >> "if you need an integer type with a specified size". Note that int32_t, >> etc. need not be any standard type - they could all be extended types >> - but if you need an exactly 32-bit type, int32_t is it (if supported >> - and if it isn't supported, you're trying to do something that can't >> be done on that platform). > > Just to pick a nit (which we are all wont to do here, right?), it is > possible that a standard (or extended) integer type exists that meets > all the requirements of int32_t, but int32_t can't be defined because > there is no type that meets the requirements of uint32_t. Or, perhaps more plausibly, vice versa. For example, a CPU might support a type that meets the requirements of uint32_t, but it use something other than 2's-complement for signed integers, or signed integer types might have padding bits, or the representation 0x80000000 might be a trap representation. Not likely on most modern architectures, but certainly permitted by the standard. -- 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"