Menu

#28 64-bit windows compatibility (mingw64)

open
spadix
None
5
2016-04-15
2012-04-02
No

A patch that introduces Windows 64-bit compatibility (using MINGW64).

Changes:
* Replaced long with ptrdiff_t for pointer arithmetic in zbar_decoder_reset (ptrdiff_t can always hold the target's system pointer operations result, and is compatible with size_t from memset) (http://www.gnu.org/software/libc/manual/html_node/Important-Data-Types.html)
* Fixed SetWindowLongPtr and SetWindowLongPtr, by replacing GWL_USERDATA with GWLP_USERDATA (http://msdn.microsoft.com/en-us/library/windows/desktop/ms644898(v=vs.85).aspx). Not sure why GWL_USERDATA worked for 32-bit mingw, maybe some backward compatibility hack in mingw32?
* Passed the zbar window class name as string to CreateWindowEx, because passing (casting) the "ATOM" no longer worked for mingw64. Maybe there is some more bright way to fix it, i don't know. (http://msdn.microsoft.com/en-us/library/windows/desktop/ms632680(v=vs.85).aspx)

Possible gotchas:
* _WIN32_WINNT is hardcoded in Mingw64 as 0x0502, so redefinition in configure.ac is commented out for mingw64 compilation. It's not a big deal, because (not including Windows XP 64-bit, which was a bit buggy and not widely used, and windows 2000 that had only 64-bit version for the Itanium processor) Win2k3 (the first implementing 0x0502 API) is the first 64 bit Windows that had 64bit version.

Tested on:
* Linux 32bit and 64bit
* Windows 2k3 32bit
* Windows 2k8 RC2 64bit

Compilation tested on (gcc --version):
gcc (GCC) 4.6.3
i486-mingw32-gcc (GCC) 4.6.2
x86_64-w64-mingw32-gcc (GCC) 4.5.4 20110822 (prerelease)

Discussion

  • Piotr Sobiech

    Piotr Sobiech - 2012-04-02

    MINGW64 compatibility patch

     
    • Summer

      Summer - 2016-07-26

      I am trying to use mingw64 compile the project which use zbar lib. I did not use patch before. Could u pls teach me how to use this patch? Thank you for ur help in advance

       
      • Vladimír Čunát

        A few months ago I side-stepped the problem by reducing the feature-set, IIRC. Here's the nix expression https://gist.github.com/vcunat/f7ebf5cd796e1d54fd13b45c8cb9c352 -- I think the configure flags used should be clear from that...

         
  • Piotr Sobiech

    Piotr Sobiech - 2012-04-02
    • assigned_to: nobody --> spadix
    • status: open --> pending
     
  • Piotr Sobiech

    Piotr Sobiech - 2012-04-02
    • status: pending --> open
     
  • Vladimír Čunát

    Is there a reason why this hasn't been integrated? Zbar-0.10 still fails to build with 64-bit mingw. (And the patch no longer applies cleanly.)

     

Log in to post a comment.