What does a type followed by _t (underscore-t) represent?

后端 未结 10 677
萌比男神i
萌比男神i 2020-11-22 07:15

This seems like a simple question, but I can\'t find it with the Stack Overflow search or Google. What does a type followed by a _t mean? Such as



        
10条回答
  •  無奈伤痛
    2020-11-22 07:31

    The _t does not inherently have any special meaning. But it has fallen into common use to add the _t suffix to typedef's.

    You may be more familiar with common C practices for variable naming... This is similar to how it's common to stick a p at the front for a pointer, and to use an underscore in front of global variables (this is a bit less common), and to use the variable names i, j, and k for temporary loop variables.

    In code where word-size and ordering is important, it's very common to use custom defined types that are explicit, such as BYTE WORD (normally 16-bit) DWORD (32-bits).

    int_t is not so good, because the definition of int varies between platforms -- so whose int are you conforming to? (Although, these days, most PC-centric development treats it as 32 bits, much stuff for non-PC development still treat int's as 16 bits).

提交回复
热议问题