News for hackers. Stuff that matters.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by _kst_ on Wednesday October 18, 2023 @01:27AM (#37925115)
A clarification: You can certainly assume that char is 8 bits if you don't mind losing portability to a small minority of systems.

If I'm being pedantic, I might add something like

    #if CHAR_BIT != 8
    #error "This code assumes 8-bit char"
    #endif
But realistically, if I'm using headers defined by either POSIX or Windows, that's probably enough of a guarantee. (Though I'd still use CHAR_BIT rather than 8 to refer to the number of bits in a byte.)
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by gpderetta on Wednesday October 18, 2023 @07:17AM (#37927137)
posix indeed guarantees CHAR_BIT == 8.