In Objective-C I often use __typeof__(obj)
when dealing with blocks etc. Why not __typeof(obj)
or typeof(obj)
.
When to use which?
__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()
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()
.)
All three mean the same thing, but none are standard C so a conforming compiler may choose to make any mean something different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With