2012-02-16 21:51:04 -07:00
|
|
|
// compile
|
2011-06-17 14:12:14 -06:00
|
|
|
|
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2012-02-23 17:48:19 -07:00
|
|
|
// Test unsafe.Sizeof, unsafe.Alignof, and unsafe.Offsetof all return uintptr.
|
|
|
|
|
2011-06-17 14:12:14 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "unsafe"
|
|
|
|
|
|
|
|
type T struct {
|
|
|
|
X int
|
|
|
|
}
|
|
|
|
|
|
|
|
var t T
|
|
|
|
|
|
|
|
func isUintptr(uintptr) {}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
isUintptr(unsafe.Sizeof(t))
|
|
|
|
isUintptr(unsafe.Alignof(t))
|
|
|
|
isUintptr(unsafe.Offsetof(t.X))
|
|
|
|
}
|