annotate libgo/misc/cgo/test/checkconst.go @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Copyright 2016 The Go Authors. All rights reserved.
kono
parents:
diff changeset
2 // Use of this source code is governed by a BSD-style
kono
parents:
diff changeset
3 // license that can be found in the LICENSE file.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 // Test a constant in conjunction with pointer checking.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 package cgotest
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 /*
kono
parents:
diff changeset
10 #include <stdlib.h>
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 #define CheckConstVal 0
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 typedef struct {
kono
parents:
diff changeset
15 int *p;
kono
parents:
diff changeset
16 } CheckConstStruct;
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 static void CheckConstFunc(CheckConstStruct *p, int e) {
kono
parents:
diff changeset
19 }
kono
parents:
diff changeset
20 */
kono
parents:
diff changeset
21 import "C"
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 import (
kono
parents:
diff changeset
24 "testing"
kono
parents:
diff changeset
25 "unsafe"
kono
parents:
diff changeset
26 )
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 func testCheckConst(t *testing.T) {
kono
parents:
diff changeset
29 // The test is that this compiles successfully.
kono
parents:
diff changeset
30 p := C.malloc(C.size_t(unsafe.Sizeof(C.int(0))))
kono
parents:
diff changeset
31 defer C.free(p)
kono
parents:
diff changeset
32 C.CheckConstFunc(&C.CheckConstStruct{(*C.int)(p)}, C.CheckConstVal)
kono
parents:
diff changeset
33 }