问题描述
我一直在想,如果有任何命名convetions当使用ALLCAPS的类型和时追加 _t
(当不使用什么吗?)。我知道,在天回K&安培; R发表的各种关于如何用C文件,但我找不到这事
I've always wondered if there are any naming convetions as when to use ALLCAPS for a type and when to append _t
(and when to not use anything?). I know back in the days K&R published all kinds of documents about how to use C, but I couldn't find anything about this.
在C标准库类型, _t
显得prettys是占主导地位
Among the C standard library types, _t
seem prettys dominant
time_t
clock_t
uint32_t
size_t
sig_atomic_t
...
,而不是文件
,的va_list
或结构TM
。是否有实际的规则来这还是完全任意?微软一直使用的ALLCAPS typenames在他们的Windows API,其中至少似乎比C库,坦率地说...
, as opposed to FILE
, va_list
or struct tm
. Are there actually rules to this or is it completely arbitrary? Microsoft always uses typenames in ALLCAPS in their Windows API, which at least seems more consistent than the C library, frankly...
推荐答案
其实根据POSIX标准,_T结尾的所有类型名称被保留,所定义的:
Actually according to the POSIX standard, all type names ending in _t are reserved, as defined here:
这与'_t'被保留额外的类型名称结尾的名称。
这篇关于的C类型的命名约定,_t或ALLCAPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!