#include <stddef.h>
int offsetof (
structure, /* structure to use */
member); /* member to get offset for */
Description
The offsetof macro calculates the offset of the member structure element from the beginning of the
structure. The structure argument must specify the
name of a structure. The member argument must
specify the name of a member of the structure.
Return Value
The offsetof macro returns the offset, in bytes, of the
member element from the beginning of struct
structure.
Example
#include <stddef.h>
struct index_st
{
unsigned char type;
unsigned long num;
unsigned ing len;
};
typedef struct index_st index_t;
void main (void) {
int x, y;
x = offsetof (struct index_st, len); /* x = 5 */
y = offsetof (index_t, num); /* y = 1 */
}
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.