github.com/varialus/godfly@v0.0.0-20130904042352-1934f9f095ab/misc/cgo/testcdefs/cdefstest.go (about) 1 // Copyright 2013 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 // +build ignore 6 7 package cgotest 8 9 /* 10 // This file tests a bug found in the cgo -cdefs tool that incorrectly 11 // translated Go pointer arrays generated by the cgo godefs tool back into C 12 // pointer arrays. 13 // 14 // The comments below show how the type is translated from gcc-style C into Go 15 // and back into C for both the buggy version and the correct version 16 17 struct cdefsTest { 18 // This was already being handled correctly 19 // Correct: -> Array [20]int8 -> int8 array[20] 20 char array1[20]; 21 22 // Buggy: -> Array [20][20]int8 -> [20]int8 array[20] 23 // Correct: -> Array [20][20]int8 -> int8 array[20][20] 24 char array2[20][20]; 25 26 // Buggy: -> Array [20]*int8 -> *int8 array[20] 27 // Correct: -> Array [20]*int8 -> int8 *array[20] 28 char *array3[20]; 29 30 // Buggy: -> Array [20][20]*int8 -> [20]*int8 array[20] 31 // Correct: -> Array [20]**int8 -> int8 *array[20][20] 32 char *array4[20][20]; 33 34 // Buggy: -> Array [20][20]**int8 -> [20]**int8 array[20] 35 // Correct: -> Array [20][20]**int8 -> int8 **array[20][20] 36 char **array5[20][20]; 37 }; 38 */ 39 import "C" 40 41 type CdefsTest C.struct_cdefsTest