Compilation for a 32-bit platform, which you can use to specify a parameter:
#include <stdio.h>
typedef int BOOL;
#define FALSE 0
#define TRUE 1
int ProcessMe(int nCommand, unsigned int wParam, long lParam)
{
*((BOOL*)wParam) = FALSE;
return 0;
}
int cast_arguments_main(int, char **)
{
BOOL bSave = TRUE;
int nOption = 0;
ProcessMe(0, (unsigned int)(&bSave), (long)(&nOption));
if(FALSE==bSave)
printf("bSave is modified!");
return 1;
}
On a 64-bit platform, the compiler complains about the impossibility of representing a pointer:
cast_arguments.cpp:17:37: error: cast from ‘BOOL*’ to ‘unsigned int’ loses precision
I had to change the declaration of the parameter unsigned int wParamto unsigned long wParamand a similar change at the point of call: ProcessMe(0, (unsigned long)(&bSave), (long)(&nOption));
but then you can simply declare the correct type for your parameter to be BOOL *. So feasibility depends on your target machine architecture ...
source
share