赞
踩

规则5.6:类型定义名称应该是唯一的标识符
Required要求类规范。
typedef名称在所有名称空间和翻译单元中应该是唯一的。只有当类型定义在头文件中并且该头文件包含在多个源文件中时,该规则才允许对相同的typedef名称进行多次声明
将一个typedef名重用为另一个typedef名,或者作为函数、对象或枚举常量的名称,可能会导致开发人员的困惑。
typedef名称可以与与typedef关联的结构、联合或枚举标记名称相同。
无
Non-compliant:违反规则
void func(void) { { typedef unsigned char u8_t; } { typedef unsigned char u8_t; /* Non-compliant - reuse */ } } typedef float mass; void func1 ( void ) { float32_t mass = 0.0f; /* Non-compliant - reuse */ } typedef struct list { struct list *next; uint16_t element; } list; /* Compliant - exception */ typedef struct { struct chain { struct chain *list; uint16_t element; } s1; uint16_t length; } chain; /* Non-compliant - tag "chain" not associated with typedef */
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。