Print this page
3373 gcc >= 4.5 concerns about offsetof()


  26 /*
  27  * Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 /*
  32  * An application should not include this header directly.  Instead it
  33  * should be included only through the inclusion of other Sun headers.
  34  *
  35  * The contents of this header is limited to identifiers specified in the
  36  * C Standard.  Any new identifiers specified in future amendments to the
  37  * C Standard must be placed in this header.  If these new identifiers
  38  * are required to also be in the C++ Standard "std" namespace, then for
  39  * anything other than macro definitions, corresponding "using" directives
  40  * must also be added to <stddef.h.h>.
  41  */
  42 
  43 #ifndef _ISO_STDDEF_ISO_H
  44 #define _ISO_STDDEF_ISO_H
  45 
  46 #pragma ident   "%Z%%M% %I%     %E% SMI" /* SVr4.0 1.5 */
  47 
  48 #include <sys/isa_defs.h>
  49 
  50 #ifdef  __cplusplus
  51 extern "C" {
  52 #endif
  53 
  54 #if __cplusplus >= 199711L
  55 namespace std {
  56 #endif
  57 
  58 #ifndef NULL
  59 #if defined(_LP64)
  60 #define NULL    0L
  61 #else
  62 #define NULL    0
  63 #endif
  64 #endif
  65 
  66 #if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
  67 #define _PTRDIFF_T


  71 typedef int     ptrdiff_t;              /* (historical version) */
  72 #endif
  73 #endif  /* !_PTRDIFF_T */
  74 
  75 #if !defined(_SIZE_T) || __cplusplus >= 199711L
  76 #define _SIZE_T
  77 #if defined(_LP64) || defined(_I32LPx)
  78 typedef unsigned long   size_t;         /* size of something in bytes */
  79 #else
  80 typedef unsigned int    size_t;         /* (historical version) */
  81 #endif
  82 #endif  /* !_SIZE_T */
  83 
  84 #if __cplusplus >= 199711L
  85 }
  86 #endif /* end of namespace std */
  87 
  88 #if __cplusplus >= 199711L
  89 #define offsetof(s, m)  (std::size_t)(&(((s *)0)->m))
  90 #else
  91 #define offsetof(s, m)  (size_t)(&(((s *)0)->m))




  92 #endif
  93 
  94 #ifdef  __cplusplus
  95 }
  96 #endif
  97 
  98 #endif  /* _ISO_STDDEF_ISO_H */


  26 /*
  27  * Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 /*
  32  * An application should not include this header directly.  Instead it
  33  * should be included only through the inclusion of other Sun headers.
  34  *
  35  * The contents of this header is limited to identifiers specified in the
  36  * C Standard.  Any new identifiers specified in future amendments to the
  37  * C Standard must be placed in this header.  If these new identifiers
  38  * are required to also be in the C++ Standard "std" namespace, then for
  39  * anything other than macro definitions, corresponding "using" directives
  40  * must also be added to <stddef.h.h>.
  41  */
  42 
  43 #ifndef _ISO_STDDEF_ISO_H
  44 #define _ISO_STDDEF_ISO_H
  45 


  46 #include <sys/isa_defs.h>
  47 
  48 #ifdef  __cplusplus
  49 extern "C" {
  50 #endif
  51 
  52 #if __cplusplus >= 199711L
  53 namespace std {
  54 #endif
  55 
  56 #ifndef NULL
  57 #if defined(_LP64)
  58 #define NULL    0L
  59 #else
  60 #define NULL    0
  61 #endif
  62 #endif
  63 
  64 #if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
  65 #define _PTRDIFF_T


  69 typedef int     ptrdiff_t;              /* (historical version) */
  70 #endif
  71 #endif  /* !_PTRDIFF_T */
  72 
  73 #if !defined(_SIZE_T) || __cplusplus >= 199711L
  74 #define _SIZE_T
  75 #if defined(_LP64) || defined(_I32LPx)
  76 typedef unsigned long   size_t;         /* size of something in bytes */
  77 #else
  78 typedef unsigned int    size_t;         /* (historical version) */
  79 #endif
  80 #endif  /* !_SIZE_T */
  81 
  82 #if __cplusplus >= 199711L
  83 }
  84 #endif /* end of namespace std */
  85 
  86 #if __cplusplus >= 199711L
  87 #define offsetof(s, m)  (std::size_t)(&(((s *)0)->m))
  88 #else
  89 #if defined(__GNUC__)
  90 #define offsetof(s, m)  __builtin_offsetof(s, m)
  91 #else
  92 #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
  93 #endif
  94 #endif
  95 
  96 #ifdef  __cplusplus
  97 }
  98 #endif
  99 
 100 #endif  /* _ISO_STDDEF_ISO_H */