4 ms·
Well, except that I don’t think most software authors actually know where it is possible to safely use an int versus one of the fixed width stdint types. In pa
by bloomer 8y ago
Well, except that I don’t think most software authors actually know where it is possible to safely use an int versus one of the fixed width stdint types. In particular, you now need to make sure that your code works correctly no matter what the actual size of an int is. This involves complicated knowledge like int promotion rules and how they will interact with different sized int, long int etc. So instead of having portable software you just have software that may fail in unexpected ways on different types of machines. I don’t actually know the rationales , but I would think that making it easier to write portable software was possibly one of the goals of introducing stdint.
- kazinator 8y agoThe promotion rules only get worse when you use a type alias like int32_t, which could be a typedef for short, int, long or conceivably even char. An expression of type int doesn't undergo any default promotion to anything, period; the widening promotion is only applied to the char and short types. An int operand may convert to the type of an opposite operand in an expression, and an int argument or return value will convert to the parameter or return value type. That applies to int32_t also. Anyway, you really have to know the rules to be working in C. Someone who uses fixed width types for everything doesn't know what they are doing and are just taking swipes at imaginary ghosts in the dark out of fear.
- deleted 8y ago[deleted]