Re: Need help with creating a GUI window on Linux using libxcb.so XCB API
- Posted by jimcbrown (admin) Jul 03, 2013
- 1440 views
Side note: I know Matt's been working on struct support for 4.1. Any chance that could make its way to returning structs-by-value via c_func/c_proc? This would help with a few other libraries as well.
We'd have to understand how compilers handle this. I've never looked to see what they do in those cases, but I agree that it would be extremely useful.
Matt
My understanding was that structs, when returned (passed by value) from a C function, will be passed on the stack. So, a struct made up of 5 elements, each being a 32bit int, will take up 20 bytes of stack space. Likewise, a struct made up of a single element, an array of bytes, with the array having a length of 12, will take up 3 dwords of stack space.
I was thinking that, in these cases, we could somehow encode the length of the struct in the return type, and return a sequence of bytes to be reconstructed by the caller.