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