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: Portable 16 bit binary integer write Date: Sun, 25 Sep 2016 15:13:39 -0700 Organization: None to speak of Lines: 28 Message-ID: References: <50a1e8f4-4fb3-4491-97d0-54768bf28685@googlegroups.com> <4fde1133-61ff-4045-9cbe-cccff1408ad3@googlegroups.com> <0b757bbb-0494-44cb-bd5a-26f117aaa404@googlegroups.com> <2cf666d7-0755-4c70-adad-07dbafc2b2e7@googlegroups.com> <09cb4413-16a6-4b63-89d0-9dafe56562f6@googlegroups.com> <68e53f3a-5fcc-44fc-90c4-bcf8dc3db680@googlegroups.com> <70ec1beb-d57b-43e7-9dcf-585aceab54bb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="30697"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xLq7aubZEvEXcHswQmCPM" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:2Wa3sqWulRwniqO1mW2Vdn2BHe0= sha1:5HS+Nx3WvH73d31uJfBQxXLn6Uo= Xref: csiph.com comp.lang.c:94058 supercat@casperkitty.com writes: > On Saturday, September 24, 2016 at 4:12:58 PM UTC-5, Keith Thompson wrote: >> Exactly how many new functions would be needed? Presumably 4 functions >> for each supported size greater than 1 byte -- but how many such sizes >> are there, and what are they? > > Signed (two's-complement) or unsigned, big-endian or little-endian, 8, 16, > 32, or 64 bits. If one assumes that data will be packed into octets rather > than into larger chunks, accommodating all possibilities would require > 16 "get" functions and 16 "put" functions. Why would you need special functions for 8-bit data? Are we assuming file data is organized into octets? Nothing in the standard currently makes that assumption. Perhaps POSIX would be a better place for this. Of course POSIX already has byte order conversion functions (htonl, htons, ntohl, ntohs). It currently only supports 16 and 32 bits; perhaps adding 64-bit versions would be useful. [...] -- 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"