Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第2章,2.3.3节有一个错误 #547

Open
gaara2016 opened this issue Aug 10, 2021 · 1 comment
Open

第2章,2.3.3节有一个错误 #547

gaara2016 opened this issue Aug 10, 2021 · 1 comment
Assignees

Comments

@gaara2016
Copy link

/*
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。

@chai2010
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants