xref: /freebsd/share/man/man3/offsetof.3 (revision ca987d4641cdcd7f27e153db17c5bf064934faf5)
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.\" $FreeBSD$
18.\"
19.Dd February 18, 2010
20.Dt OFFSETOF 3
21.Os
22.Sh NAME
23.Nm offsetof
24.Nd offset of a structure member
25.Sh SYNOPSIS
26.In stddef.h
27.Ft size_t
28.Fn offsetof "type" "member"
29.Sh DESCRIPTION
30The
31.Fn offsetof
32macro expands to an integer constant expression of type
33.Ft size_t
34and yields the offset,
35in bytes, of the field
36.Ar member
37from the start of the structure
38.Ar type .
39.Pp
40A compiler error will result if
41.Ar member
42is not aligned to a byte boundary (i.e. it is a bit-field).
43.Sh STANDARDS
44The
45.Fn offsetof
46macro conforms to
47.St -ansiC .
48