summaryrefslogtreecommitdiff
path: root/misc/cgo/testcdefs/cdefstest.go
blob: e6305b77d7cafd6010b45cd30d7d23ea69de10f8 (plain)
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
// Copyright 2013 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.
//
// +build ignore

package cgotest

/*
// This file tests a bug found in the cgo -cdefs tool that incorrectly
// translated Go pointer arrays generated by the cgo godefs tool back into C
// pointer arrays.
//
// The comments below show how the type is translated from gcc-style C into Go
// and back into C for both the buggy version and the correct version

struct cdefsTest {
	// This was already being handled correctly
	// Correct: -> Array [20]int8 -> int8 array[20]
	char array1[20];

	// Buggy:   -> Array [20][20]int8 -> [20]int8 array[20]
	// Correct: -> Array [20][20]int8 -> int8 array[20][20]
	char array2[20][20];

	// Buggy:   -> Array [20]*int8 -> *int8 array[20]
	// Correct: -> Array [20]*int8 -> int8 *array[20]
	char *array3[20];

	// Buggy:   -> Array [20][20]*int8 -> [20]*int8 array[20]
	// Correct: -> Array [20]**int8 -> int8 *array[20][20]
	char *array4[20][20];

	// Buggy:   -> Array [20][20]**int8 -> [20]**int8 array[20]
	// Correct: -> Array [20][20]**int8 -> int8 **array[20][20]
	char **array5[20][20];
};
*/
import "C"

type CdefsTest C.struct_cdefsTest