Get/SetWindowLongPtr

From: Paul Forgey (not)
Date: 10/04/04

  • Next message: manoj: "How To Start a service"
    Date: Sun, 3 Oct 2004 18:12:46 -0700
    
    

    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?


  • Next message: manoj: "How To Start a service"

    Relevant Pages

    • Re: Convert short to float
      ... >> avoid redundant casting if code compiles without ... > for an error, disable the warning (using a pragma, not a ... If you use a cast and later change the type ... it's quite dificult to avoid ...
      (microsoft.public.vc.language)
    • Re: Whats wrong with this sentence?
      ... The intention behind using generics is to avoid surprises for the JVM. ... You should use generics to avoid runtime(class cast) exceptions. ... So in this case you are ought to get this warning in eclipse. ... class ItemInfoMap extends HashMapimplements ...
      (comp.lang.java.programmer)
    • Re: SetClassLongPtr broken?
      ... {// The call to SetWindowLongPtr here may generate a warning when ... data // // It is safe to ignore this warning because it is bogus per MSDN Magazine. ... #undef GetWindowLongPtrA ...
      (microsoft.public.win32.programmer.ui)
    • Re: SetClassLongPtr broken?
      ... :-) I mean I get a warning that I'm throwing away some precision, and sure enough it turns out I am, ... problem with SetWindowLongPtr in the same project, ... SetWindowLong are the same and SetClassLongPtr and SetClassLong are the ... If and when I target the Win64 platform, ...
      (microsoft.public.win32.programmer.ui)
    • Re: SetClassLongPtr broken?
      ... // It is safe to ignore this warning because it is bogus per MSDN ... if (lastError) throw LastErrorException; ... So apparently when I encountered this warning for SetWindowLongPtr I was ...
      (microsoft.public.win32.programmer.ui)