Difference between typeof, __typeof and __typeof__ in Objective-C

objective-c

Solution

`__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.

Problem

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

Original source

Related problems