3 ms·
I looked at the C99 and C11 specs and sure enough, there's nothing that says sizeof( int ) == sizeof( unsigned int ). But I would think it would be common enou
by retrocryptid 4y ago
I looked at the C99 and C11 specs and sure enough, there's nothing that says sizeof( int ) == sizeof( unsigned int ). But I would think it would be common enough you could assume it's true. I mean, have you ever seen a machine made after 1970 where sizeof( int ) and sizeof( unsigned int ) were different? (or short / unsigned short, long / unsigned long, long long / unsigned long long). I suspect this is a no-go since you went to the trouble of posting this question.
I'm sure you could do it byte by byte and hope the compiler could optimize it.
(I don't have the C17 spec around, so maybe someone else could check it didn't add that constraint, in which case my response would be "Of course! just use C17!")