4.2.7. Keywords for related base classes

The following keywords enable you to determine the offset from the beginning of an object to a related base class within it:

__offsetof_base(D, B)

B must be a non-virtual base class of D.

Returns the offset from the beginning of a D object to the start of the B base subobject within it. The result might be zero. It is the offset (in bytes) that must be added to a D* p to implement the equivalent of static_cast<B*>(p). For example:

__asm B* my_static_base_cast(D* /*p*/) {
    if __offsetof_base(D, B) <> 0 // optimise zero offset case
        ADD r0, r0, #__offsetof_base(D, B)
    endif
    MOV pc, lr
}

These keywords are converted into integer or logical constants in the assembler source. You can only use them in __asm functions, but not in a __cpp expression.

Copyright © 2003, 2004 ARM Limited. All rights reserved.ARM DUI 0232B
Non-Confidential