[issue5710] ctypes should return composite types from callbacks

Pam McA'Nulty report at bugs.python.org
Wed Nov 22 08:42:20 EST 2017


Pam McA'Nulty <pamela at mcanulty.org> added the comment:

In the example code, the 'result' variable is declared on the stack in the callback() function.  So it will be effectively when callback() returns.

Also the "result" variable in main() is never referenced.  A pointer main()'s "result" variable should be passed to callback() as an argument ("&result") and `callback(struct helloStruct *result)` should populate it (via `result->i = 10;` etc)

```struct helloStruct callback () {
  struct helloStruct result;
  result.i = 10;
  result.f = 3.14159;
  return result;
}```

----------
nosy: +Pam.McANulty

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue5710>
_______________________________________


More information about the Python-bugs-list mailing list