github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/test/execution/unsafe/offsetof.go (about)

     1  // RUN: llgo -o %t %s
     2  // RUN: %t 2>&1 | FileCheck %s
     3  
     4  // CHECK: 0
     5  // CHECK-NEXT: 4
     6  // CHECK-NEXT: 8
     7  // CHECK-NEXT: 16
     8  
     9  package main
    10  
    11  import "unsafe"
    12  
    13  type S struct {
    14  	a int16
    15  	b int32
    16  	c int8
    17  	d int64
    18  }
    19  
    20  func main() {
    21  	var s S
    22  	println(unsafe.Offsetof(s.a))
    23  	println(unsafe.Offsetof(s.b))
    24  	println(unsafe.Offsetof(s.c))
    25  	println(unsafe.Offsetof(s.d))
    26  }