SetWindowLong(hWnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams));
warning C4311: 'type cast' : pointer truncation from 'LPVOID' to 'long'
//AND
(IApplication*)(GetWindowLong(hWnd, GWL_USERDATA));
warning C4312: 'type cast' : conversion from 'LONG' to Impulse::Core::IApplication *' of greater size
type cast warnings
I have two warnings when I try to type cast. There probably not a big deal since I used the code from a book. Its when you use a static window procedure and type cast it into the class. The code from the book compiles fine. Is there something in the compiler settings?
A pointer may be bigger than a long, e.g. on a 64-bit platform. There's an option to disable that check in the project settings.
I couldn't find anything. I don't know what it would say or where it would be. I am using vs2003. I did fix the first warning with PtrToUlong()
You can use #pragma's to disable these sort of warnings. I'd just encapsulate them in #ifdef _WIN32/#endif so you can keep them completely OS independant. 2 lines of code makes life much easier.
*sigh*
(Solution Explorer)→(Project name)→(Right Click)→Properties→C/C++→General→Detect 64-bit Portability Issues→No.
Or just don't cast your pointers to LONG (size_t is a safer bet).
(Solution Explorer)→(Project name)→(Right Click)→Properties→C/C++→General→Detect 64-bit Portability Issues→No.
Or just don't cast your pointers to LONG (size_t is a safer bet).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement