advanced-go-programming-book icon indicating copy to clipboard operation
advanced-go-programming-book copied to clipboard

第2章,2.3.3节有一个错误

Open gaara2016 opened this issue 2 years ago • 1 comments

/* struct A { int size: 10; // 位字段无法访问 float arr[]; // 零长的数组也无法访问 }; */ import "C" import "fmt"

func main() { var a C.struct_A fmt.Println(a.size) // 错误: 位字段无法访问 fmt.Println(a.arr) // 错误: 零长的数组也无法访问 } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int size: 10 无法访问。 int size: 8、16或者32。 可以访问,打印结果:a.size=0。

gaara2016 avatar Aug 10 '21 08:08 gaara2016

零长的数组好像是C99的特性,如果C++不支持可以用 float arr[1] 先绕过

chai2010 avatar Sep 23 '21 09:09 chai2010