basic question about adresses and values in structs

evilrat via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 4 03:29:05 PDT 2014


On Thursday, 4 September 2014 at 09:54:57 UTC, nikki wrote:
> thanks! just what I needed, with some stumbling I managed to 
> get everything working as intended: using a pointer variable to 
> save an adres of a function, then dereferencing to use it.
>
> Now I am wondering when to use the ** ?
>
> for example I found this function over at 
> https://github.com/d-gamedev-team/gfm/blob/master/core/gfm/core/memory.d
>
> void* storeRawPointerAndReturnAligned(void* raw, size_t 
> alignment) nothrow
>     {
>         enum size_t pointerSize = size_t.sizeof;
>         char* start = cast(char*)raw + pointerSize;
>         void* aligned = nextAlignedPointer(start, alignment);
>         void** rawLocation = cast(void**)(cast(char*)aligned - 
> pointerSize);
>         *rawLocation = raw;
>         return aligned;
>     }
>
> it's a little over my head yet..

void** (double ptr) is a pointer to array of pointers(just 
imagine a crossword where each horizontal letter is part of 
vertical word) there is little reason to use them in D, mostly to 
C/C++ interfacing


More information about the Digitalmars-d-learn mailing list