Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The offsetof() macro is defined by the C Standard as a portable way to determine the offset, expressed in bytes, from the start of the object to a given member of that object. The C Standard, subclause 7.17, paragraph 3 [ISO/IEC 9899:1999], specifies, in part:

...

When specifying the type argument for the offsetof() macro, only pass a standard-layout class. The full description of a standard-layout class can be found in Clause clause 9 of the C++ Standard, or the type can be checked with the std::is_standard_layout<> type trait. When specifying the member designator argument for the offsetof() macro, do not pass a bit-field, static data member, or function member. Passing an invalid type or member to the offsetof() macro is undefined behavior.

...

Bibliography

[ISO/IEC 9899:1999]Subclause 7.17, "Common Definitions <stddef.h>"
[ISO/IEC 14882-2014]18

Subclause 9.4.2, "

Types

Static Data Members"

9Subclause 18.4.2, "Static Data MembersTypes" 

 

...