Files
oldlinux-files/study/Ref-docs/C/stddef.html
2024-02-19 00:25:23 -05:00

93 lines
3.6 KiB
HTML

<HTML><HEAD><TITLE>&lt;stddef.h&gt;</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">
<H1><A NAME="&lt;stddef.h&gt;"><CODE>&lt;stddef.h&gt;</CODE></A></H1><HR>
<P><CODE>
#define <A HREF="#NULL"><B>NULL</B></A>
<I>&lt;either 0, 0L, or (void *)0&gt;</I> <B>[0 in C++]</B><BR>
#define <A HREF="#offsetof"><B>offsetof</B></A>(<I>s-type</I>,
mbr) <I>%lt;</I>size_t <I>constant expression&gt;</I><BR>
typedef <I>si-type</I>
<A HREF="#ptrdiff_t"><B>ptrdiff_t</B></A>;<BR>
typedef <I>ui-type</I> <A HREF="#size_t"><B>size_t</B></A>;<BR>
typedef <I>i-type</I> <A HREF="#wchar_t"><B>wchar_t</B></A>;
<B>[keyword in C++]</B>
</CODE></P>
<P>Include the standard header <B><CODE>&lt;stddef.h&gt;</CODE></B>
to define several types and macros that are
of general use throughout the program. The
standard header <CODE>&lt;stddef.h&gt;</CODE> is available even in a
<A HREF="lib_over.html#freestanding implementation" tppabs="http://ccs.ucsd.edu/c/lib_over.html#freestanding implementation">
freestanding implementation</A>.</P>
<H2><A NAME="NULL"><CODE>NULL</CODE></A></H2>
<P><CODE>
#define <B>NULL</B> <I>&lt;either 0, 0L, or (void *)0&gt;</I>
<B>[0 in C++]</B>
</CODE></P>
<P>The macro yields a null pointer constant that is usable as an
<A HREF="express.html#address constant expression" tppabs="http://ccs.ucsd.edu/c/express.html#address constant expression">
address constant expression</A>.</P>
<H2><A NAME="offsetof"><CODE>offsetof</CODE></A></H2>
<P><CODE>
#define <B>offsetof</B>(<I>s-type</I>, mbr)
<I>%lt;</I>size_t <I>constant expression&gt;</I>
</CODE></P>
<P>The macro yields the offset in bytes, of type
<A HREF="#size_t"><CODE>size_t</CODE></A>,
of member <CODE>mbr</CODE> from
the beginning of structure type <CODE><I>s-type</I></CODE>,
where for <CODE>X</CODE> of type <CODE><I>s-type</I></CODE>,
<CODE>&amp;X.mbr</CODE> is an
<A HREF="express.html#address constant expression" tppabs="http://ccs.ucsd.edu/c/express.html#address constant expression">
address constant expression</A>.</P>
<H2><A NAME="ptrdiff_t"><CODE>ptrdiff_t</CODE></A></H2>
<P><CODE>
typedef <I>si-type</I> <B>ptrdiff_t</B>;
</CODE></P>
<P>The type is the signed integer type <CODE><I>si-type</I></CODE>
of an object that you declare to store the result of
subtracting two pointers.</P>
<H2><A NAME="size_t"><CODE>size_t</CODE></A></H2>
<P><CODE>
typedef <I>ui-type</I> <B>size_t</B>;
</CODE></P>
<P>The type is the unsigned integer type <CODE><I>ui-type</I></CODE>
of an object that you declare to store the result of the
<A HREF="express.html#sizeof operator" tppabs="http://ccs.ucsd.edu/c/express.html#sizeof operator"><I>sizeof</I></A> operator.</P>
<H2><A NAME="wchar_t"><CODE>wchar_t</CODE></A></H2>
<P><CODE>
typedef <I>i-type</I> <B>wchar_t</B>; <B>[keyword in C++]</B>
</CODE></P>
<P>The type is the integer type <CODE><I>i-type</I></CODE> of a
<A HREF="charset.html#wide-character constant" tppabs="http://ccs.ucsd.edu/c/charset.html#wide-character constant">
wide-character constant</A>, such as <CODE>L'X'</CODE>.
You declare an object of type <CODE>wchar_t</CODE> to hold a
<A HREF="charset.html#Wide-Character Encoding" tppabs="http://ccs.ucsd.edu/c/charset.html#Wide-Character Encoding">wide character</A>.</P>
<HR>
<P>See also the
<B><A HREF="index.html#Table of Contents" tppabs="http://ccs.ucsd.edu/c/index.html#Table of Contents">Table of Contents</A></B> and the
<B><A HREF="_index.html" tppabs="http://ccs.ucsd.edu/c/_index.html">Index</A></B>.</P>
<P><I>
<A HREF="crit_pb.html" tppabs="http://ccs.ucsd.edu/c/crit_pb.html">Copyright</A> &#169; 1989-1996
by P.J. Plauger and Jim Brodie. All rights reserved.</I></P>
</BODY></HTML>