id and ObjC interfaces

Hi all,

In clang, type 'id' is implemented as 'typedef struct objc_object *'.
And 'id' can points to any ObjC objects. Does that mean that all ObjC
interfaces inherits 'struct objc_object' implicitly?

-Zhongxing

I don't know how clang handle this but AFAK, the first ivar of a root class must be a pointer on the object class (usually named isa) (this is the case for NSObject and NSProxy for example).
So, an interface should not inherit struct objc_object, else the isa pointer will be defined twice.

Type for 'id' is:

typedef struct objc_object {
     Class isa;
} *id;

'id' gcc and clang predefine this type. It is essentially a 'void *' for objective-c object pointers.
This does not mean that ObjC interfaces inherit 'id'. It does mean that ObjC object pointers can be
assigned back and force to objects of this type.

- Fariborz

Thanks for all replies.