Thread overview | |||||
---|---|---|---|---|---|
|
October 11, 2003 out struct parameters are by value!? | ||||
---|---|---|---|---|
| ||||
I have a C function, whose effective signature is: void __stdcall Recls_GetSizeProperty(recls_info_t fileInfo, recls_filesize_t *size); recls_info_t is actually a typedef of a pointer to a structure. Hence, the first argument is 4 bytes. recls_filesize_t is, in Win32, a FILETIME structure. Hence the second argument is 4 bytes. In D, I declared it as public struct recls_time_t { uint dwLowDateTime; uint dwHighDateTime; }; extern(Windows) { . . . private void Recls_GetSizeProperty(in recls_info_t fileInfo, out recls_filesize_t size); However, this fails to link. It cannot find _Recls_GetSizeProperty@12 which clearly indicates that the out parameter is by value. If I define it as extern(Windows) { . . . private void Recls_GetSizeProperty(in recls_info_t fileInfo, recls_filesize_t *size); It links fine. This seems more than a little odd. What if the struct is very large? In fact, why is an out parameter passed by value? And how is the out-ness effected? Very odd. Please explain. Matthew |
October 11, 2003 Re: out struct parameters are by value!? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Clarification: the size is not FILETIME. (That's the time!). It's actually a ulong. "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bm7hj0$20pq$1@digitaldaemon.com... > I have a C function, whose effective signature is: > > void __stdcall Recls_GetSizeProperty(recls_info_t fileInfo, > recls_filesize_t *size); > > recls_info_t is actually a typedef of a pointer to a structure. Hence, the > first argument is 4 bytes. > recls_filesize_t is, in Win32, a FILETIME structure. Hence the second > argument is 4 bytes. > > In D, I declared it as > > public struct recls_time_t > { > uint dwLowDateTime; > uint dwHighDateTime; > }; > > extern(Windows) > { > . . . > > private void Recls_GetSizeProperty(in recls_info_t fileInfo, out > recls_filesize_t size); > > However, this fails to link. It cannot find _Recls_GetSizeProperty@12 which > clearly indicates that the out parameter is by value. If I define it as > > extern(Windows) > { > . . . > > private void Recls_GetSizeProperty(in recls_info_t fileInfo, > recls_filesize_t *size); > > It links fine. > > This seems more than a little odd. What if the struct is very large? > > In fact, why is an out parameter passed by value? And how is the out-ness effected? Very odd. > > Please explain. > > Matthew > > |
October 11, 2003 Re: out struct parameters are by value!? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | The struct *is* passed by reference. It's the name mangling generated by the compiler that's wrong. "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bm7hj0$20pq$1@digitaldaemon.com... > I have a C function, whose effective signature is: > > void __stdcall Recls_GetSizeProperty(recls_info_t fileInfo, > recls_filesize_t *size); > > recls_info_t is actually a typedef of a pointer to a structure. Hence, the > first argument is 4 bytes. > recls_filesize_t is, in Win32, a FILETIME structure. Hence the second > argument is 4 bytes. > > In D, I declared it as > > public struct recls_time_t > { > uint dwLowDateTime; > uint dwHighDateTime; > }; > > extern(Windows) > { > . . . > > private void Recls_GetSizeProperty(in recls_info_t fileInfo, out > recls_filesize_t size); > > However, this fails to link. It cannot find _Recls_GetSizeProperty@12 which > clearly indicates that the out parameter is by value. If I define it as > > extern(Windows) > { > . . . > > private void Recls_GetSizeProperty(in recls_info_t fileInfo, > recls_filesize_t *size); > > It links fine. > > This seems more than a little odd. What if the struct is very large? > > In fact, why is an out parameter passed by value? And how is the out-ness effected? Very odd. > > Please explain. > > Matthew > > |
Copyright © 1999-2021 by the D Language Foundation