1.\" $NetBSD: offsetof.3,v 1.3 2010/12/19 08:10:09 jruoho Exp $ 2.\" 3.\" $OpenBSD: offsetof.3,v 1.2 2010/02/18 18:30:19 jmc Exp $ 4.\" 5.\" Copyright (c) 2010 Thomas Pfaff <tpfaff@tp76.info> 6.\" 7.\" Permission to use, copy, modify, and distribute this software for any 8.\" purpose with or without fee is hereby granted, provided that the above 9.\" copyright notice and this permission notice appear in all copies. 10.\" 11.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18.\" 19.\" 20.Dd December 19, 2010 21.Dt OFFSETOF 3 22.Os 23.Sh NAME 24.Nm offsetof 25.Nd offset of a structure member 26.Sh SYNOPSIS 27.In stddef.h 28.Ft size_t 29.Fn offsetof "type" "member" 30.Sh DESCRIPTION 31The 32.Fn offsetof 33macro expands to an integer constant expression of type 34.Ft size_t 35and yields the offset, 36in bytes, of the field 37.Ar member 38from the start of the structure 39.Ar type . 40.Pp 41A compiler error will result if 42.Ar member 43is not aligned to a byte boundary (i.e. it is a bit-field). 44.Sh SEE ALSO 45.Xr __alignof__ 3 , 46.Xr stddef 3 , 47.Xr typeof 3 48.Sh STANDARDS 49The 50.Fn offsetof 51macro conforms to 52.St -ansiC . 53