• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/17_lib_ffi/11_offsetof

  1 The `ffi.offsetof()` function returns the byte offset of a struct field.
  2 
  3 Field offsets in a struct with padding.
  4 
  5 -- Testcase --
  6 {%
  7 import * as ffi from 'ffi';
  8 
  9 ffi.cdef('typedef struct { char a; int b; short c; } st;');
 10 
 11 print("offsetof(a): ", ffi.offsetof('st', 'a'), "\n");
 12 print("offsetof(b): ", ffi.offsetof('st', 'b'), "\n");
 13 print("offsetof(c): ", ffi.offsetof('st', 'c'), "\n");
 14 -- End --
 15 
 16 -- Expect stdout --
 17 offsetof(a): 0
 18 offsetof(b): 4
 19 offsetof(c): 8
 20 -- End --
 21 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt