Reputation:
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
?
Upvotes: 2
Views: 2051
Reputation: 28806
There is no uniform way.
Simple function returns, like int
s 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 struct
s). The fact that different compilers use different strategies to return struct
s, even on the same platform and using the same calling convention, has made me issue the warning that one should never return struct
s from, say, DLL functions.
More info:
Upvotes: 7