Get/SetWindowLongPtr

P

Paul Forgey

When building on a 32 bit target, the following:

Something *somethingPtr;
.....
SetWindowLongPtr (wnd, GWLP_USERDATA, (LONG_PTR) somethingPtr);

warns of a conversion from LONG_PTR to LONG. Uhh.. the whole point of the
_ptr types is to describe, in a platform independent manner, a numeric type
whose size will hold a pointer. I have to cast it from something to avoid
another (correct) warning because it's a pointer type being cast to an
integer.

This is happening because on non-win64, SetWindowLongPtr is actually
SetWindowLong, which takes a LONG type. Fine and good ,but why then is the
compiler warning me the LONG_PTR -> LONG is a possible loss of data while
they should really be aliases of the same type?

So while this will work great on win64, there's no way to avoid a warning on
one platform or the other without an #ifdef, something the _ptr types are
there to avoid having to do. WTF?! Am I missing yet another ugly __MACRO
that needs to be set to something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top