Passing this to void *

Adam D. Ruppe destructionator at gmail.com
Wed Nov 22 15:37:48 UTC 2017


On Wednesday, 22 November 2017 at 15:23:58 UTC, Tim Hsu wrote:
>    m_window = glfwCreateWindow();
>    glfwSetWindowUserPointer(m_window, cast(void *)(&this));

That that & out of there!

glfwSetWindowUserPointer(m_window, cast(void *)(this));

without the &, you are fine.


Then, on the other side, you cast back. Again, do NOT dereference 
it, just cast it:

App app = cast(App) user_ptr;


More information about the Digitalmars-d-learn mailing list