stddef.h(0P)
π PROLOG π
ok so before we even get into it: this manual page is part of the POSIX Programmer's Manual. but bestie, heads up β the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface might not even be implemented on Linux at all. π
β¨ NAME β¨
stddef.h β standard type definitions. literally the blueprint of "what even is a pointer difference" π
πΈ SYNOPSIS πΈ
#include <stddef.h>
that's it. that's the whole vibe. one include and you're in. π«Ά
π DESCRIPTION π
so everything described on this reference page is aligned with the ISO C standard. and like, any conflict between the requirements described here and the ISO C standard? not intentional, bestie, we promise. this volume of POSIX.1β2017 defers to the ISO C standard. periodt.
the <stddef.h> header shall define the following macros:
NULLβ the null pointer constant. this macro shall expand to an integer constant expression with the value0cast to typevoid *. yes, the cast is the whole point, iykyk.offsetof(type, member-designator)β an integer constant expression of typesize_t, whose value is the offset in bytes to the structure member (member-designator), measured from the beginning of its structure (type). it's giving "where am i in this struct" energy. π¦
and the <stddef.h> header shall also define the following types:
ptrdiff_tβ signed integer type of the result of subtracting two pointers. subtraction but make it a type. πwchar_tβ integer type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales; the null character shall have the code value zero. each member of the basic character set shall have a code value equal to its value when used as the lone character in an integer character constant if an implementation does not define__STDC_MB_MIGHT_NEQ_WC__. okay that last part is very specific and we are keeping every word of it. πsize_tβ unsigned integer type of the result of thesizeofoperator. the icon. the moment. the legend.
and here's a thing the implementation shall do: support one or more programming environments in which the widths of ptrdiff_t, size_t, and wchar_t are no greater than the width of type long. and if you wanna know the names of these programming environments? you can get them using the confstr() function or the getconf utility. π§
the following sections are informative. (translation: the real rules already happened, this is the commentary track β¨)
π APPLICATION USAGE π
None.
like, genuinely none. nothing to say. no notes. π
π RATIONALE π
ok so the tea: the ISO C standard does not require the NULL macro to include the cast to type void *, and it specifies that the NULL macro be implementation-defined.
but POSIX.1β2008 requires the cast β and therefore it need not be implementation-defined. slay, honestly. POSIX said "we'll take it from here." π«Ά
β FUTURE DIRECTIONS β
None.
the future is, apparently, exactly the same. iconic behavior. πΈ
π¦ SEE ALSO π¦
<sys_types.h>,<wchar.h>- The System Interfaces volume of POSIX.1β2017,
confstr() - The Shell and Utilities volume of POSIX.1β2017,
getconf
π₯ COPYRIGHT π₯
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.
in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. (yes, the original is the main character here, not this page. respect.) the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
ngl if something looks cursed in here it's probably a conversion glitch, not a design choice π
and that's the whole page bestie!! brought to you by IEEE/The Open Group, 2017, filed under stddef.h(0P) β go forth and offsetof responsibly πβ¨π
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms