__BUILTIN_TYPES_COMPATIBLE_P函数
来源:互联网 发布:js修改div id 编辑:程序博客网 时间:2024/05/29 04:21
__BUILTIN_TYPES_COMPATIBLE_P
名字: __builtin_types_compatible_p
GNU扩展,用来判断两个类型是否相同
原型
int __builtin_types_compatible_p(type_a, type_b);
描述:
此函数为GNU扩展,用来判断两个类型是否相同,如果type_a
与 type_b
相同的话,就会返回1,否则的话,返回0。
请注意一下情景:
两个类型的sizeof值跟它的类型判断是相互不影响的,例如:在i386架构下,
sizeof(char *)
和sizeof(int)
的值是相同的,但是他们的类型却是不相同的。限定符会被忽略,例如
const long
和long
他们的类型是相同的。相同的类型不同的指针级数是不相同的例如:
double*
和double**
是不相同的。连个用
typedef
定义的类型,当且进档他们定义的类型是相同的时候,=它们是相同的。enum
类型是一种特殊的情况,两个enum
类型是不相同的。
原文
__BUILTIN_TYPES_COMPATIBLE_P(3) Library Functions ManualNAME __builtin_types_compatible_p - GNU extension to check equivalent typesSYNOPSIS int __builtin_types_compatible_p(type_a, type_b);DESCRIPTION The __builtin_types_compatible_p() is a GNU extension for determining whether two types are equivalent. If type_a is equivalent to type_b, a value 1 is returned. Otherwise __builtin_types_compatible_p() returns 0. The following remarks should be taken into account. 1.The architecture-specific size of the two types does not have an impact on the result. For example, sizeof(char *) and sizeof(int) result the same value on i386, but the types naturally are not equivalent. 2.Type qualifiers are ignored. The function returns the same value for long and const long. 3. The amount of pointer indirection affects the result. For example, double * is not equivalent to double **. 4.Two types defined with typedef are equivalent if and only if their underlying types are equivalent. 5. The enum type is a special case in that two enum types are not considered equivalent.EXAMPLES The following example combines __builtin_types_compatible_p() and the typeof(3) construct: #define __COMPARE_TYPES(v, t) \ __builtin_types_compatible_p(__typeof__(v), t) ... if (__COMPARE_TYPES(p, double) != 0) err(EX_DATAERR, "invalid type");SEE ALSO gcc(1), __builtin_constant_p(3), typeof(3)CAVEATS This is a non-standard, compiler-specific extension.NetBSD 7.99 December 21, 2010
0 0
- __BUILTIN_TYPES_COMPATIBLE_P函数
- GCC内联函数:__builtin_types_compatible_p
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- oracle 监听启动、停止、查看命令
- dicom文件元素组成
- android studio jar
- SSO单点登录、ajax跨域重定向、跨域设置Cookie、京东单点登录实例分析
- 定制android ROM禁止SIM卡状态改变系统弹出提示框
- __BUILTIN_TYPES_COMPATIBLE_P函数
- Android .9.png制作
- jsonUnexpected token,字符串编码不一致等的终极解决办法
- 免费API接口收集
- php中如何去除字符串中的空格
- Cgroup 图文版操作练习(转载)
- C语言中字符串的几种定义方式
- SQL业务审核与优化
- Jinja2模板(1) --基本概念,模板引擎,渲染模板