Why does everybody typedef over standard C types?

前端 未结 4 1904
执笔经年
执笔经年 2020-12-12 23:19

If you want to use Qt, you have to embrace quint8, quint16 and so forth.

If you want to use GLib, you have to welcome

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 00:04

    So you have the power to typedef char to int.

    One "coding horror" mentioned that one companies header had a point where a programmer wanted a boolean value, and a char was the logical native type for the job, and so wrote typedef bool char. Then later on someone found an integer to be the most logical choice, and wrote typedef bool int. The result, ages before Unicode, was virtually typedef char int.

    Quite a lot of forward-thinking, forward compatibility, I think.

提交回复
热议问题