stddef.h

From Wikipedia, the free encyclopedia

C Standard Library headers

stddef.h is a header file in the standard library of the C programming language which defines the macro NULL and the types ptrdiff_t, wchar_t, and size_t.

Contents

[edit] Inclusion

In C, one includes the header file "stddef.h", as in:

#include <stddef.h>
/* ... */

In C++, one includes the header file "cstddef", as in:

#include <cstddef>
// ...

[edit] Namespace

The header file "stddef.h" places its definitions in the global scope; the header file "cstddef" places size_t and ptrdiff_t in namespace std.

[edit] NULL

Main article: NULL

A macro that represents the null pointer value. It may be defined as ((void*)0), 0 or 0L depending on the compiler and the language (C vs C++).

[edit] Type size_t

Main article: size_t

The type size_t represents the appropriate type for representing the size of objects of memory areas, and for use in dereferencing the elements of an array. It has an implementation-dependent size; usually, it has a 32-bit representation on 32-bit systems and a 64-bit representation on 64-bit systems. It may be signed or unsigned. It has a signed variation, ssize_t, defined in the UNIX header file, "unistd.h".

[edit] Type wchar_t

Main article: wchar_t

An implementation-specific "wide character" type, which is predefined in the C++ programming language but requires the header "stddef.h" or "wchar.h" in the C programming language.

[edit] Type ptrdiff_t

Main article: ptrdiff_t

The type ptrdiff_t is a type that can hold the result of subtracting two pointers. The underlying type of ptrdiff_t varies from implementation to implementation.

[edit] External references

Languages