4 ms·
Is there any production-level C code which relies on (int+bool, and other semantically meaningless arithmetic) working? Besides, C++ broke nevertheless broke C
by zvrba 11y ago
Is there any production-level C code which relies on (int+bool, and other semantically meaningless arithmetic) working?
Besides, C++ broke nevertheless broke C compatibility because ++bool will never increment the value past 1, and bool=int will coerce int to 0 or 1. C will preserve the original values.
- pjmlp 11y ago> Is there any production-level C code which relies on (int+bool, and other semantically meaningless arithmetic) working? Yes. I have seen enterprise code making interesting tricks to covert handle values into pointers, back in the late 90's.
- the_why_of_y 11y agoCode that switches over a variable nominally declared to be of type BOOL and handles more than 2 distinct value cases is always such a joy to read; every enterprise grade code base should have at least one of these for entertainment purposes.