Skip to main content
gamedev.net
🔒 Locked

warning C4312

Started by wasd Oct 31, 2005 at 8:51 AM 1 replies 3.6k views
Original Post
wasd
wasd
I'm getting the warning: warning C4312: 'type cast' : conversion from 'int' to 'void *' of greater size At the moment I'm not too bothered about 64-bit portability, but if I want to convert my program to 64 bit in future, I want to know if I can still do this. What I have is a class with a member of type (void *). The member is used to store custom data for passing to another function, where it's converted back to the appropriate type. In this case, I'm converting from an int to a (void *), then in the function converting back to an int. Is there a better way which is similar to this to store custom data and pass it to a function?
chollida1
chollida1
windows defines the *_PTR types ie DWORD_PTR INT_PTR that are designed to be the size of a pointer. You could use those. That's what we ported our code to use.

CHeers
chris
CheersChris
Promit
Promit
More generally speaking, std::size_t is guaranteed to be the same size as a pointer, and unsigned, while std::ptrdiff_t is guaranteed to be the same size as a pointer, and signed.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.