sizeof_basic.go
1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// RUN: llgo -o %t %s
// RUN: %t 2>&1 | FileCheck %s
// CHECK: 1
// CHECK-NEXT: 8
// CHECK-NEXT: 1
// CHECK-NEXT: 2
// CHECK-NEXT: 4
// CHECK-NEXT: 8
// CHECK-NEXT: 8
// CHECK-NEXT: 1
// CHECK-NEXT: 2
// CHECK-NEXT: 4
// CHECK-NEXT: 8
// CHECK-NEXT: 4
// CHECK-NEXT: 8
// CHECK-NEXT: 8
// CHECK-NEXT: 16
// CHECK-NEXT: 16
// CHECK-NEXT: 8
// CHECK-NEXT: 8
// CHECK-NEXT: 1
// CHECK-NEXT: 8
// CHECK-NEXT: 1
// CHECK-NEXT: 2
// CHECK-NEXT: 4
// CHECK-NEXT: 8
// CHECK-NEXT: 8
// CHECK-NEXT: 1
// CHECK-NEXT: 2
// CHECK-NEXT: 4
// CHECK-NEXT: 8
// CHECK-NEXT: 4
// CHECK-NEXT: 8
// CHECK-NEXT: 8
// CHECK-NEXT: 8
// CHECK-NEXT: 8
// CHECK-NEXT: 8
// CHECK-NEXT: 8
package main
import "unsafe"
func main() {
var b bool
var i int
var i8 int8
var i16 int16
var i32 int32
var i64 int64
var u uint
var u8 uint8
var u16 uint16
var u32 uint32
var u64 uint64
var f32 float32
var f64 float64
var c64 complex64
var c128 complex128
var s string
var p unsafe.Pointer
var up uintptr
println(unsafe.Sizeof(b))
println(unsafe.Sizeof(i))
println(unsafe.Sizeof(i8))
println(unsafe.Sizeof(i16))
println(unsafe.Sizeof(i32))
println(unsafe.Sizeof(i64))
println(unsafe.Sizeof(u))
println(unsafe.Sizeof(u8))
println(unsafe.Sizeof(u16))
println(unsafe.Sizeof(u32))
println(unsafe.Sizeof(u64))
println(unsafe.Sizeof(f32))
println(unsafe.Sizeof(f64))
println(unsafe.Sizeof(c64))
println(unsafe.Sizeof(c128))
println(unsafe.Sizeof(s))
println(unsafe.Sizeof(p))
println(unsafe.Sizeof(up))
println(unsafe.Alignof(b))
println(unsafe.Alignof(i))
println(unsafe.Alignof(i8))
println(unsafe.Alignof(i16))
println(unsafe.Alignof(i32))
println(unsafe.Alignof(i64))
println(unsafe.Alignof(u))
println(unsafe.Alignof(u8))
println(unsafe.Alignof(u16))
println(unsafe.Alignof(u32))
println(unsafe.Alignof(u64))
println(unsafe.Alignof(f32))
println(unsafe.Alignof(f64))
println(unsafe.Alignof(c64))
println(unsafe.Alignof(c128))
println(unsafe.Alignof(s))
println(unsafe.Alignof(p))
println(unsafe.Alignof(up))
}