0

the c code:

struct RangeResult { int bsucc; int size; const char *contents[]; };

extern struct RangeResult get_range(void*, unsigned int key, int limit, unsigned int max_limit);

the go code:

ret := C.get_range(filesdb, C.uint(1), 100, 1000) for i := 0; i < int(ret.size); i++ { fmt.Println("value:", C.GoString(ret.contents[i])) }

go build error message:

/gofilesdb.go: In function '_cgo_2e3328a0efbe_Cfunc_get_range': ./gofilesdb.go:86:7: note: the ABI of passing struct with a flexible array member has changed in GCC 4.4

how to fix this problem?

  • Someone with the same problem [here](https://stackoverflow.com/questions/8883439/getting-the-following-warning-the-abi-of-passing-struct-with-a-flexible-array) getting the error because they are trying to pass the struct by value. Same issue? – Lundin Feb 25 '20 at 09:36
  • I don't know how the C function could possibly work as intended, even in C. The size of a structure with a flexible array member is as though the array is zero length. So if you return such a struct type from a function, or pass it by value or copy it by assignment, the returned struct, function parameter, or result of assignment will have no contents in the flexible array member. – Ian Abbott Feb 25 '20 at 10:20

0 Answers0