Programming Tips - How can I avoid MS VC++ warning C4311:

Date: 2010apr8 Language: C/C++ Product: MSVC++ Q. How can I avoid MS VC++ warning C4311:
warning C4311: 'type cast' : pointer truncation from '<pointer>' to 'LONG'
A. You can disable the warning temporarily like this:
#pragma warning(push) #pragma warning(disable: 4311) LONG my_long = (LONG) my_pointer; #pragma warning(pop)
Or you can use a builtin inline function to do the conversion (nicer):
LONG my_long = PtrToLong(my_pointer);
More of these here: http://msdn.microsoft.com/en-us/library/aa384267.aspx