Skip to content

Common definitions (stddef.h)

Include stddef.h for common C definitions used by library headers and portable data-structure code.

Types and Macros

Name Meaning
size_t Unsigned 16-bit object size type.
ptrdiff_t Signed 16-bit pointer difference type.
wchar_t Unsigned 16-bit wide character type.
NULL Null pointer constant.
offsetof Compile-time byte offset of member within type.

Runtime model

The DCC C Compiler is a 16-bit target: size_t, ptrdiff_t, and object pointers are all 16-bit. wchar_t is an unsigned 16-bit type and matches the representation used for wide string literals.

NULL is defined as 0 if no earlier header has defined it. It is suitable as a null pointer constant in pointer contexts.

Offsets

offsetof(type, member) is folded by the compiler and produces the byte offset of a struct or union member. It accepts nested member designators and constant array indexes:

#include <stddef.h>

struct rec {
    char tag;
    int  value;
};

int off = offsetof(struct rec, value);   /* 1 on this 16-bit target */

Use ptrdiff_t for pointer subtraction results and size_t for sizes and object counts that follow the standard library interfaces.

#include <stddef.h>

ptrdiff_t span(char *first, char *last)
{
    return last - first;
}