I want to call a function that returns a struct, this function has the __cdecl calling convention.
How does the __cdecl calling convention returns a struct?
I want to call a function that returns a struct, this function has the __cdecl calling convention.
How does the __cdecl calling convention returns a struct?
There is no uniform way.
Simple function returns, like ints are returned in registers, but none of the calling conventions, __cdecl, __stdcall, etc. describe how exactly a struct is returned.
structs by reference, i.e. the function result is compiled as a void function taking an extra pointer argument to such a struct. I have had big problems with this (DLL functions that return structs). The fact that different compilers use different strategies to return structs, even on the same platform and using the same calling convention, has made me issue the warning that one should never return structs from, say, DLL functions.
More info: