D: Declaring empty pointer variables that return address inside function calls?
BoQsc
vaidas.boqsc at gmail.com
Thu Nov 23 20:13:59 UTC 2023
On Thursday, 23 November 2023 at 20:00:31 UTC, H. S. Teoh wrote:
> On Thu, Nov 23, 2023 at 07:22:22PM +0000, BoQsc via
> Digitalmars-d-learn wrote:
>> Is it possible to declare empty pointer variable inside
>> function calls and pass its address to the function?
>>
>> These are sometimes required while using Win32 - Windows
>> Operating System API.
>>
>> * Empty pointer variables are used by functions to return
>> information after the function is done.
>>
>> My own horrible **suggestion** of empty pointer declaration
>> inside
>> function call:
>> `someFunction(uint & passingEmptyVariableForWrite);`
>>
>> What it would do:
>> * A new variable is declared inside function call.
>> * Address of that variable is passed to the function.
>> * After function is done, you can refer to it for returned
>> value.
>
> What's wrong with:
>
> uint* result;
> someFunction(&result);
> // use *result
>
> ?
>
>
> T
Nothing wrong. It would be just a more concise compact way to do
the same.
Also I mostly wanted to know if something like that is already
possible in D language.
It's not a huge loss if it is not possible.
More information about the Digitalmars-d-learn
mailing list