Standard C Libraries -. More...
Go to the source code of this file.
Macros | |
#define | NULL (0) |
#define | offsetof(T, mbr) ((int)&(((T *)0)->mbr)) |
Typedefs | |
typedef __PTRDIFF_TYPE__ | ptrdiff_t |
typedef __SIZE_TYPE__ | size_t |
typedef __WCHAR_TYPE__ | wchar_t |
Standard C Libraries -.
The header file, stddef.h, consists of several types and macros that are of general use in programs.
The documentation in this header file has been copied from the documentation provided with the Microchip MPLAB XC16 compiler. The original license agreement included with the XC16 compiler applies!
#define NULL (0) |
Description: The value of a null pointer constant.
Include: <stddef.h>
#define offsetof | ( | T, | |
mbr | |||
) | ((int)&(((T *)0)->mbr)) |
Description: Gives the offset of a structure member from the beginning of the structure.
Include: <stddef.h>
T | name of structure |
mbr | name of member in structure T |
Remarks:
The macro offsetof is undefined for bitfields. An error message will occur if bitfields are used.
Example:
Output:
Explanation:
This program shows the offset in bytes of each structure member from the start of the structure. Although item1 is only 5 bytes (char item1[5]), padding is added so the address of item2 falls on an even boundary. The same occurs with item3; it is 1 byte (char item3) with 1 byte of padding.
typedef __PTRDIFF_TYPE__ ptrdiff_t |
Description: The type of the result of subtracting two pointers.
Include: <stddef.h>
typedef __SIZE_TYPE__ size_t |
Description: The type of the result of the sizeof operator.
Include: <stddef.h>