pass a struct by value/ref and size of the struct
Johan Engelen via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 22 05:35:59 PDT 2016
On Monday, 21 March 2016 at 23:31:06 UTC, ref2401 wrote:
> I have got a plenty of structs in my project. Their size varies
> from 12 bytes to 128 bytes.
> Is there a rule of thumb that states which structs I pass by
> value and which I should pass by reference due to their size?
Note that the compiler may do things different from what you may
have expected. For example for C code, the platform ABI may
already dictate passing of your structs by pointer reference,
even though your code says "by value". See:
https://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
MSVC will pass structs that are larger than 64 bits (8 bytes) by
reference in C++ code. Your D compiler may decide to do the same.
More information about the Digitalmars-d-learn
mailing list