Fputc semantics for conforming C implementations

Source: Hacker News

Article note: I was talking about the weirdness of bool the other day and hit on some of the "char is a little special because of machines that don't have 8-bit byte addressing, and ABIs that disagree about signedness" ... but I wasn't thinking about how char oddness would interact with putc and getc. It is a little bit non-obvious what the "right" thing is, since if you're on, say, a DSP that has only 16bit addressing, you don't really want to write out "abc" as "a\0b\0c\0" even though that is what you sent it bitwise, and you also don't want to silently discard data or have something read back differently than it wrote out. Not a problem most places because POSIX says CHAR_BIT=8, but it'll still fuck you up in the edge caes. ...and then there's unicode, let's not think about that.
Comments
This entry was posted in News. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *