3 ms·
> What type errors? Do you mean that, to get it to compile as C++, you have to add an explicit cast? Yes. > That isn't a significant burden. But once you do
by josefx 6y ago
> What type errors? Do you mean that, to get it to compile as C++, you have to add an explicit cast?
Yes.
> That isn't a significant burden.
But once you do it your "C" code is littered with a lot of unnecessary casts that increase the verbosity of the code and could hide errors. With pre C99 code it would also hide default int errors if the include for malloc gets lost at some point.
- MaxBarraclough 6y ago> and could hide errors How? As I said, the stricter rules of C++ result in fewer type-conversion errors than C's permissive rules. That's the reason for C++'s stricter rules, and it's the reason Ada is even stricter. As an example, consider a = b = c; In a languages with permissive rules about implicit conversions, you have to inspect the variables' types to determine whether this statement is equivalent to b = c; a = c; (Even ignoring OOP, that is.) > With pre C99 code it would also hide default int errors if the include for malloc gets lost at some point. Wouldn't it just fail to compile if you're missing a required header? edit steveklabnik linked to [0] so I see what you mean now. I think that's a valid point. [0] https://stackoverflow.com/a/605858/ https://stackoverflow.com/a/605858/