Best Practices: Should I create a typedef for byte in C or C++?

前端 未结 6 1669
情歌与酒
情歌与酒 2021-02-07 05:40

Do you prefer to see something like t_byte* (with typedef unsigned char t_byte) or unsigned char* in code?

I\'m leaning towards

6条回答
  •  清歌不尽
    2021-02-07 06:04

    I prefer to use standard types, unsigned char, uint8_t, etc., so any programmer looking at the source does not have to refer back to headers to grok the code. The more typedefs you use the more time it takes for others to get to know your typing conventions. For structures, absolutely use typedefs, but for primitives use them sparingly.

提交回复
热议问题