Package: manpages-dev
Version: 2.28-1
Severity: wishlist
Tags: patch

Included is a manpage documenting the offsetof() macro; please
consider including it.

.\" Copyright (C) 2006 Justin Pryzby <[EMAIL PROTECTED]>
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
.\" a copy of this software and associated documentation files (the
.\" "Software"), to deal in the Software without restriction, including
.\" without limitation the rights to use, copy, modify, merge, publish,
.\" distribute, sublicense, and/or sell copies of the Software, and to
.\" permit persons to whom the Software is furnished to do so, subject to
.\" the following conditions:
.\"
.\" The above copyright notice and this permission notice shall be
.\" included in all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
.\" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
.\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
.\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
.\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.\"
.\" References:
.\"   /usr/lib/gcc/i486-linux-gnu/4.1.1/include/stddef.h
.\"   glibc-doc
.TH ERROR 3 "2006-05-23" GNU
.SH NAME
offsetof \- offset of a structure member
.SH SYNOPSIS
\fB#include <stddef.h>

\fBsize_t offsetof(\fItype\fP, \fPmember\fP);
.SH DESCRIPTION
\fBoffsetof\fP() is a macro provided to compute the offset of a given
element within a structure.  The ordering within memory of a C
structure is undefined, as is its size; compilers are allowed to
reorder and pad structures.  An element's offset is not necessarily
given by the sum of the sizes of the previous elements' sizes; use
\fBoffsetof\fP() instead.
.SH "RETURN VALUE"
\fBoffsetof\fP() returns the offset of the given element within the
given datatype, in units of bytes.
.SH EXAMPLE PROGRAM
.nf
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
        struct a {
                int i;
                char c;
                double d;
        };

        /* Output is compiler-dependant */
        printf("%d\n", offsetof(struct a, c));
        exit(EXIT_SUCCESS);
}
.fi
.SH NOTES
\fBoffsetof\fP can be implemented as:
.sp
.nf
        \fB#define offsetof(\fItype\fP, \fPmember\fP) \\
                \fB&((type *)0)->\fImember\fP - (char *)((\fPtype\fP *)0)
.fi
.SH "CONFORMING TO"
\fBoffsetof\fP() is a POSIX requirement.
.\" .SH SEE ALSO


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to