当我运行这段代码时,我希望打印出像A: 4, B: 89. 但实际上,不显示任何内容。
为什么这个程序不向标准输出显示结果?
main.go:
package main
/*
#include "c.h"
*/
import "C"
import (
"unsafe"
)
type S struct {
A int
B int
}
func main() {
s := &S{A: 4, B: 89}
pass_to_c := (*C.S)(unsafe.Pointer(s))
C.gostruct(pass_to_c)
}
ch
#include <stdio.h>
#include <stdlib.h>
typedef struct {
long int A;
long int B;
} S;
extern void gostruct(S *struct_s) {
printf("A: %ld, B: %ld\n", struct_s->A, struct_s->B);
}
慕的地10843
慕桂英3389331
相关分类