Visual Studio 2008 - building 32 & 64 bit now!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LanceDiamond
    Rookie
    • Apr 2009
    • 13

    Visual Studio 2008 - building 32 & 64 bit now!

    Took about 2 days to sort out but now I can build either 32 bit (x86) or 64 bit (x64) 3.1.0 beta using VS2008 on 64 bit Vista. Simple as changing my build config. I'm so proud of myself.

    No clue why I did this - happy to share the main-win.c if anyone is interested. I actually didn't have to change that much though some of what I had to do would probably be viewed as an awful hack by any sane person.
  • Pete Mack
    Prophet
    • Apr 2007
    • 6883

    #2
    Getting it to build is a good start. The question is: does it work?

    Comment

    • LanceDiamond
      Rookie
      • Apr 2009
      • 13

      #3
      Originally posted by Pete Mack
      Getting it to build is a good start. The question is: does it work?
      Haha fine point!

      Guess I should have been a bit more clear - yes, it works - haven't actually played much with 64 bit yet, but I'm going to start a new char right now with the x64 binary and play a while. I have loaded a savefile from an old char I'd played in 32bit and it loads and I can move around etc.

      Building an x64 binary was surprisingly easy. Tracking down what was causing the x64 binary to crash upon execution was time consumning. Fixing what was wrong was not too difficult. How I fixed it is where the awful hack comes in.

      Comment

      • LanceDiamond
        Rookie
        • Apr 2009
        • 13

        #4
        64 bit is working fine - no awful hack any more either. I had been manually changing a pointer but then I noticed if I just changed SetWindowLong to SetWindowLongPtr that wasn't necessary.

        The change necessary for 64 bit Windows were all around the assumption that a pointer is 4 bytes. That's correct for 32 bit but for 64 bit, a pointer is 8 bytes.

        With the changes I made, both 32 and 64 bit compile and work.

        Changes:

        main-win.c, WinMain function
        Code:
        wc.cbWndExtra    = 4; /* one long pointer to term_data */
        changed to
        Code:
        wc.cbWndExtra    = sizeof(LONG_PTR); // 4 on 32bit, 8 on 64bit
        main-win.c, several places
        Code:
        td = (term_data *)GetWindowLong(hWnd, 0);
        changed to
        Code:
        td = (term_data *)GetWindowLongPtr(hWnd, 0);
        main-win.c, several places
        Code:
        SetWindowLong(hWnd, 0, (LONG)(my_td));
        changed to
        Code:
        SetWindowLongPtr(hWnd, 0, (LONG_PTR)(my_td));

        Comment

        • PaulBlay
          Knight
          • Jan 2009
          • 657

          #5
          Originally posted by LanceDiamond
          64 bit is working fine - no awful hack any more either.
          Well it didn't break anything on my 32 bit compile so I've borrowed the code.
          Currently turning (Angband) Japanese.

          Comment

          • LanceDiamond
            Rookie
            • Apr 2009
            • 13

            #6
            Glad to help - if you're curious about the new version of the functions:

            SetWindowLongPtr


            GetWindowLongPtr
            Retrieves information about the specified window. The function also retrieves the value at a specified offset into the extra window memory. (ANSI)


            Looks like they were created to enable code that is compatible with 32-bit and 64-bit Windows.

            Comment

            Working...
            😀
            😂
            🥰
            😘
            🤢
            😎
            😞
            😡
            👍
            👎