www.delorie.com/gnu/docs/glibc/libc_687.html   search  
Buy the book!

The GNU C Library

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.5.4 Structure Field Offset Measurement

You can use offsetof to measure the location within a structure type of a particular structure member.

Macro: size_t offsetof (type, member)
This expands to a integer constant expression that is the offset of the structure member named member in a the structure type type. For example, offsetof (struct s, elem) is the offset, in bytes, of the member elem in a struct s.

This macro won't work if member is a bit field; you get an error from the C compiler in that case.

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003