C++ TargetRTS
Loading...
Searching...
No Matches
RTFieldOffset.h
1/*
2 * Licensed Materials - Property of HCL and/or IBM
3 * Copyright HCL Technologies Ltd. 2016, 2021. All Rights Reserved.
4 * Copyright IBM Corporation 1999, 2016. All Rights Reserved.
5 *
6 * U.S. Government Users Restricted Rights - Use, duplication or
7 * disclosure restricted by GSA ADP Schedule.
8 */
9
10#ifndef __RTFieldOffset_h__
11#define __RTFieldOffset_h__ included
12
13#ifdef PRAGMA
14#pragma interface
15#endif
16
17#ifndef __RTConfig_h__
18#include <RTConfig.h>
19#endif
20
21#include <stddef.h>
22
23typedef size_t RTFieldOffset; // Used for storing byte offset for a field, and byte size of types
24
25#define RTOffsetOf( type, field ) \
26 ( ( reinterpret_cast<RTFieldOffset>(reinterpret_cast<char *>(&( (reinterpret_cast<type *>(sizeof( type )))->field ) )) \
27 - sizeof( type )) )
28
29#define RTObjectOf( type, offset, object ) \
30 ( reinterpret_cast<type *>( (reinterpret_cast<char *>(object)) + (offset) ) )
31
32#define RTConstObjectOf( type, offset, object ) \
33 ( reinterpret_cast<const type *>( (reinterpret_cast<const char *>(object)) + (offset) ) )
34
35#endif // __RTFieldOffset_h__