CKTIS / C
stddef.h — common definitions
The <stddef.h> header supplies common types and macros. Include it directly wherever you use them.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <stddef.h>size_t is unsigned and describes the result of sizeof; ptrdiff_t is signed and describes pointer differences.
offsetof(type, member-designator) gives a byte offset as size_t; do not use it for bit-fields.
max_align_t provides the greatest fundamental alignment, while wchar_t represents wide characters.
NULL is a null pointer constant macro. In C23, nullptr_t names the type of nullptr, distinct from pointer types. Reaching unreachable() causes undefined behavior.
Examples
#include <stddef.h>
#include <stdio.h>
struct Item {
int value;
};
int main(void)
{
int values[3] = {10, 20, 30};
size_t count = sizeof values / sizeof values[0];
ptrdiff_t distance = &values[2] - &values[0];
printf("count=%zu distance=%td offset=%zu\n",
count, distance, offsetof(struct Item, value));
return 0;
}
Result
count=3 distance=2 offset=0
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.