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