VirtualBox

Changeset 33692 in vbox for trunk/include


Ignore:
Timestamp:
Nov 2, 2010 2:51:20 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67318
Message:

iprt/cdefs.h: Added RT_FROM_CPP_MEMBER for shutting up mr noisy (g++).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cdefs.h

    r33540 r33692  
    11411141/** @def RT_FROM_MEMBER
    11421142 * Convert a pointer to a structure member into a pointer to the structure.
     1143 *
    11431144 * @returns pointer to the structure.
    11441145 * @param   pMem    Pointer to the member.
     
    11471148 */
    11481149#define RT_FROM_MEMBER(pMem, Type, Member)      ( (Type *) ((uint8_t *)(void *)(pMem) - RT_UOFFSETOF(Type, Member)) )
     1150
     1151/** @def RT_FROM_CPP_MEMBER
     1152 * Same as RT_FROM_MEMBER except it avoids the annoying g++ warnings about
     1153 * invalid access to non-static data member of NULL object.
     1154 *
     1155 * @returns pointer to the structure.
     1156 * @param   pMem    Pointer to the member.
     1157 * @param   Type    Structure type.
     1158 * @param   Member  Member name.
     1159 *
     1160 * @remarks Using the __builtin_offsetof does not shut up the compiler.
     1161 */
     1162#if defined(__GNUC__) && defined(__cplusplus)
     1163# define RT_FROM_CPP_MEMBER(pMem, Type, Member) \
     1164        ( (Type *) ((uintptr_t)(pMem) - (uintptr_t)&((Type *)0x1000)->Member + 0x1000U) )
     1165#else
     1166# define RT_FROM_CPP_MEMBER(pMem, Type, Member) RT_FROM_MEMBER(pMem, Type, Member)
     1167#endif
    11491168
    11501169/** @def RT_ELEMENTS
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette