Suppose I have a function
void foo(char *)
which, internally, needs to treat its input as a block of NUL-terminated bytes (say, it's a hash function on strings). I could cast the argument to unsigned char*
in the function. I could also change the declaration to
void foo(unsigned char *)
Now, given that char
, signed char
and unsigned char
are three different types, would this constitute an interface change, under any reasonable definition of the term "interface" in C?
(This question is intended to settle a discussion raised by another question. I have my opinions, but will not accept an answer until one comes up as a "winner" by the votes of others.)
According to ISO/IEC 9899:TC3,
char
, signed char
and unsigned char
are different basic types (6.2.5 §14) and thus incompatible (6.2.7 §1), which is also explicitly mentioned in footnote 35 on page 35So yes, this is clearly a change to the programming interface.
However, as char *
, signed char *
and unsigned char *
will have identical representations and alignment requirements in any sane implementation of the C language, the binary interface will remain unchanged.
Yes it is. Client code which previously compiled will no longer compile (or anyway is likely to generate new warnings), so this is a breaking change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With