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

Split Close
Expand all
Collapse all
          --- old/usr/src/head/iso/stddef_iso.h
          +++ new/usr/src/head/iso/stddef_iso.h
↓ open down ↓ 35 lines elided ↑ open up ↑
  36   36   * C Standard.  Any new identifiers specified in future amendments to the
  37   37   * C Standard must be placed in this header.  If these new identifiers
  38   38   * are required to also be in the C++ Standard "std" namespace, then for
  39   39   * anything other than macro definitions, corresponding "using" directives
  40   40   * must also be added to <stddef.h.h>.
  41   41   */
  42   42  
  43   43  #ifndef _ISO_STDDEF_ISO_H
  44   44  #define _ISO_STDDEF_ISO_H
  45   45  
  46      -#pragma ident   "%Z%%M% %I%     %E% SMI" /* SVr4.0 1.5 */
  47      -
  48   46  #include <sys/isa_defs.h>
  49   47  
  50   48  #ifdef  __cplusplus
  51   49  extern "C" {
  52   50  #endif
  53   51  
  54   52  #if __cplusplus >= 199711L
  55   53  namespace std {
  56   54  #endif
  57   55  
↓ open down ↓ 23 lines elided ↑ open up ↑
  81   79  #endif
  82   80  #endif  /* !_SIZE_T */
  83   81  
  84   82  #if __cplusplus >= 199711L
  85   83  }
  86   84  #endif /* end of namespace std */
  87   85  
  88   86  #if __cplusplus >= 199711L
  89   87  #define offsetof(s, m)  (std::size_t)(&(((s *)0)->m))
  90   88  #else
  91      -#define offsetof(s, m)  (size_t)(&(((s *)0)->m))
       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
  92   94  #endif
  93   95  
  94   96  #ifdef  __cplusplus
  95   97  }
  96   98  #endif
  97   99  
  98  100  #endif  /* _ISO_STDDEF_ISO_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX