Unix/Linux Go Back    

NetBSD 6.1.5 - man page for offsetof (netbsd section 3)

Linux & Unix Commands - Search Man Pages
Man Page or Keyword Search:   man
Select Man Page Set:       apropos Keyword Search (sections above)

OFFSETOF(3)			   BSD Library Functions Manual 		      OFFSETOF(3)

     offsetof -- offset of a structure member

     #include <stddef.h>

     offsetof(type, member);

     The offsetof() macro expands to an integer constant expression of type size_t and yields the
     offset, in bytes, of the field member from the start of the structure type.

     A compiler error will result if member is not aligned to a byte boundary (i.e. it is a bit-

     Regardless of the architecture and the ABI, the following example prints the value zero for
     the variable x.

	   struct example {
		   double  x;
		   int	   y;
		   char    z;

	   size_t x, y, z;

	   x = offsetof(struct example, x);
	   y = offsetof(struct example, y);
	   z = offsetof(struct example, z);

	   (void)printf("%zu %zu %zu\n", x, y, z);

     __alignof__(3), stddef(3), typeof(3)

     The offsetof() macro conforms to ANSI X3.159-1989 (``ANSI C89'').

BSD					  April 1, 2011 				      BSD
Unix & Linux Commands & Man Pages : ©2000 - 2018 Unix and Linux Forums

All times are GMT -4. The time now is 03:06 PM.