Cast to pointer-to-pointer-to-void

Hi,

(This is for DirectX programming but is general in nature so I thought it fit better in this forum.)

In section 5.2.4 of the book Introduction to 3D Game Programming with DirectX (Google Books link below), when polling the mouse the author calls GetDeviceState() and passes the second parameter which is declared as LPVOID, as (void**)&mMouseState. mMouseState is of type structure DIMOUSESTATE2 (not a pointer to one).

I'm curious why the author is casting the address of the structure to pointer-to-pointer-to-void instead of just omitting the cast entirely. Can someone tell me what I'm missing and what exactly the (void**) is achieving in this context?

Many thanks.

Book link: http://books.google.com/books?id=is6Wc3hKSWIC&printsec=frontcover&dq=introduction+to+3d+game+programming
Think of it as passing the address of a pointer. Another way to think of it is passing a pointer by reference.

The net effect it the pointer can be made to point to something else.
Thanks for the reply. The sticky point for me is why it is (void**) and not just (void*) if the parameter type is LPVOID?
Last edited on
Probably a mistake. As far as I can tell, void * and void ** are identical.
Topic archived. No new replies allowed.