29.10.2014 Views

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Using</strong> <strong>the</strong> Inline and Embedded Assemblers of <strong>the</strong> <strong>ARM</strong> <strong>Compiler</strong><br />

7.39 __offsetof_base keyword <strong>for</strong> related base classes in embedded assembler<br />

The __offsetof_base keyword enables you to determine <strong>the</strong> offset from <strong>the</strong> beginning of an<br />

object to a base class sub-object within it:<br />

__offsetof_base(D, B)<br />

B must be an unambiguous, nonvirtual base class of D.<br />

Returns <strong>the</strong> offset from <strong>the</strong> beginning of a D object to <strong>the</strong> start of <strong>the</strong> B base<br />

subobject within it. The result might be zero. Example 7-5 shows <strong>the</strong> offset (in<br />

bytes) that must be added to a D* p to implement <strong>the</strong> equivalent of<br />

static_cast(p).<br />

Example 7-5 static_cast(p)<br />

__asm B* my_static_base_cast(D* /*p*/) // equivalent to:<br />

// return static_cast(p)<br />

{<br />

if __offsetof_base(D, B) 0 // optimize zero offset case<br />

ADD r0, r0, #__offsetof_base(D, B)<br />

endif<br />

BX lr<br />

}<br />

The __offsetof_base, __mcall_*, and _vcall_offsetof_vfunc keywords are converted into<br />

integer or logical constants in <strong>the</strong> assembler source. You can only use it in __asm functions, not<br />

in __cpp expressions.<br />

7.39.1 See also<br />

Concepts<br />

• Restrictions on embedded assembly language functions in C and C++ code on page 7-40<br />

• <strong>Compiler</strong> support <strong>for</strong> embedded assembler on page 7-36.<br />

<strong>ARM</strong> DUI 0375C Copyright © 2007-2008, 2011 <strong>ARM</strong>. All rights reserved. 7-46<br />

ID061811<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!