I have a code
void(*updateFunc)(EW_Window*) = ((GlfwWindow*)wnd->wndData)->updateCallback;
if (updateFunc)
updateFunc(wnd);
And if (updateFunc)
always passes even updateFunc
is 0xcdcdcd (null in debugger).
What's going wrong and how I can fix it?
CodePudding user response:
0xcdcdcd
is not null-pointer, it is a pattern used to mark unitialized memory. That value is considered as a true
value in C. The problem is that ((GlfwWindow*)wnd->wndData)->updateCallback
has a wrong value...
CodePudding user response:
Do you mean
void(*updateFunc)(EW_Window*) = ((GlfwWindow*)wnd )->wndData->updateCallback;