13.15 cstddef

   

13.15 <cstddef>

The <cstddef> header is the C++ version of the C standard <stddef.h> header, which declares a few types and macros.

The C header declares the wchar_t type, but wchar_t is a reserved keyword in C++, so there is no need to #include <cstddef> to declare this type.

NULL macro Null pointer

 #define  NULL   . .  . 

The NULL macro expands to a null pointer constant, such as or 0L .

figs/acorn.gif

Some C libraries declare NULL as ((void*)0) in stddef.h . This definition is fine for C, but is wrong for C++. Most C++ compilers correctly declare NULL , but you should be aware of the difference.

offsetof macro Computes member offset

 size_t  offsetof  (   type   ,   member-name   ) 

The offsetof macro returns the offset, in bytes, of a member of a struct as a constant integer. The type must be a plain, C-style struct (Plain Old Data, or POD), and the expression &(t . member-name ) must be an address constant, assuming t is an instance of type . In particular, this means the member-name must not be a bit-field, a static member, or a function member. (See Chapter 6 for more information about POD types.)

ptrdiff_t type Pointer difference type

 typedef ...  ptrdiff_t  

figs/acorn.gif

The ptrdiff_t type is a signed integral type that represents the difference between two pointers. The exact type is implementation-defined.

size_t type sizeof result type

 typedef ...  size_t  

figs/acorn.gif

The size_t type is the type of the result of the sizeof operator. It is an unsigned integral type. The exact type is implementation-defined.

   


C++ in a Nutshell
C++ in a Nutshell
ISBN: 059600298X
EAN: 2147483647
Year: 2005
Pages: 270
Authors: Ray Lischner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net