signed integer type capable of holding a pointer to void
2025-11-16
Written by: xiaobin
The default version uses MSVC >=1930, which is Visual Studio 2022.
I find intptr_t rather less useful, except possibly as a way station when casting,
to avoid the dread warning about changing signedness and integer size in the same cast.
(Writing portable code that passes -Wall -Werror on all relevant architectures can be a bit of a struggle.)
Also, intptr_t is the C99/C++11 standard alternative, but INT_PTR predates them.
MFC App Wizard
Generate dialog-based
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
else if (nResponse == -1)
{
TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n");
TRACE(traceAppMsg, 0, "Warning: if you are using MFC controls on the dialog, you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n");
}
It’s not recommended to use definitions from the operating system when you don’t need them!