2

Follow-up question for this answer.

Is there any hosted C implementations (__STDC_HOSTED__ is 1) which have CHAR_BIT > 8?

If so, then which ones?

UPD. Fix typo: before: __STDC_HOSTED__ is 0, after: __STDC_HOSTED__ is 1.

pmor
  • 5,392
  • 4
  • 17
  • 36
  • Do you want a real implementation running on a commercial computer hardware which could be bought in 2021, or is a "virtual machine" acceptable? – Basile Starynkevitch Mar 14 '21 at 17:20
  • 1
    Wouldn't that imply an architecture with not 8-bit bytes? – Mad Physicist Mar 14 '21 at 17:20
  • @BasileStarynkevitch. And in the latter case, do you accept something someone threw together just to prove a point? – Mad Physicist Mar 14 '21 at 17:21
  • You could make such a bizarre architecture with FPGA, but it won't be cost-effective – Basile Starynkevitch Mar 14 '21 at 17:21
  • 1
    Is this relevant: [What platforms have something other than 8-bit char?](https://stackoverflow.com/q/2098149/10871073) – Adrian Mole Mar 14 '21 at 17:23
  • @MadPhysicist: today http://www.madphysicist.com/ is not responding on Sun 14 Mar 2021 05:23:12 PM UTC – Basile Starynkevitch Mar 14 '21 at 17:23
  • 1
    Any such implementation could not claim POSIX conformance (see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html#tag_13_23_03_06) and probably couldn't run any current-generation generic embedded OS either, so there's a great deal of incentive for hardware designers to avoid doing things that would necessitate a larger CHAR_BIT. – zwol Mar 14 '21 at 17:34
  • 4
    @MadPhysicist Thre's nothing in the C standard that says that the number of bits in `char` has to be 8. – JeremyP Mar 14 '21 at 17:46
  • @JeremyP. No, only that a `char` be one byte, hence my comment. – Mad Physicist Mar 14 '21 at 17:57
  • @MadPhysicist: C implementations do not have to directly use the bytes or other features of the architecture their programs execute on. It is reasonable for a C implementation to provide a model suitable to some old or special purpose C code. – Eric Postpischil Mar 14 '21 at 18:57
  • @AdrianMole Sure, `__STDC_HOSTED__` is `1`. Fixed. Thanks. – pmor Mar 15 '21 at 08:34

1 Answers1

3

I don't know if there was ever a post-standardisation version, but various Cray 64-bit vector supercomputers had a C compiler in which sizeof(long) == sizeof(double) == 1, a.k.a. everything is 64 bits wide.

mlp
  • 809
  • 7
  • 21