Objc.checkTupleof

Issues a compile time error if the .offsetof/.tupleof property is used on a field of an Objective-C class.

To solve the fragile base class problem in Objective-C, fields have a dynamic offset instead of a static offset. The compiler outputs a statically known offset which later the dynamic loader can update, if necessary, when the application is loaded. Due to this behavior it doesn't make sense to be able to get the offset of a field at compile time, because this offset might not actually be the same at runtime.

To get the offset of a field that is correct at runtime, functionality from the Objective-C runtime can be used instead.

  1. void checkOffsetof(Expression expression, AggregateDeclaration aggregateDeclaration)
  2. void checkTupleof(Expression expression, TypeClass type)
    class Objc
    abstract const
    void
    checkTupleof

Parameters

expression Expression

the .offsetof/.tupleof expression

type TypeClass

the type of the receiver of the .tupleof expression

See Also

Suggestion Box / Bug Report