Objective-C中的typeof,__ typeof和__typeof__之间的区别 [英] Difference between typeof, __typeof and __typeof__ in Objective-C

查看:500
本文介绍了Objective-C中的typeof,__ typeof和__typeof__之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Objective-C中,我经常在处理块等时使用__typeof__(obj).为什么不使用__typeof(obj)typeof(obj).

In Objective-C I often use __typeof__(obj) when dealing with blocks etc. Why not __typeof(obj) or typeof(obj).

何时使用哪个?

推荐答案

__typeof__()__typeof()是C语言特定于编译器的扩展,因为标准C不包含此类运算符.标准C要求编译器在语言扩展之前加上双下划线(这也是为什么您永远不要为自己的函数,变量等使用前缀的原因)

__typeof__() and __typeof() are compiler-specific extensions to the C language, because standard C does not include such an operator. Standard C requires compilers to prefix language extensions with a double-underscore (which is also why you should never do so for your own functions, variables, etc.)

typeof()完全相同,但是在理解每个现代编译器都支持的情况下,将下划线放在了窗口之外. (实际上,既然考虑到这一点,Visual C ++可能不会.尽管它确实支持decltype(),但通常提供与typeof()相同的行为.)

typeof() is exactly the same, but throws the underscores out the window with the understanding that every modern compiler supports it. (Actually, now that I think about it, Visual C++ might not. It does support decltype() though, which generally provides the same behaviour as typeof().)

这三者均表示同一件事,但都不是标准C语言,因此合格的编译器可能会选择使任何意思有所不同.

All three mean the same thing, but none are standard C so a conforming compiler may choose to make any mean something different.

这篇关于Objective-C中的typeof,__ typeof和__typeof__之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆