![]() |
#1 |
Rookie
Join Date: Apr 2009
Posts: 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. |
![]() |
![]() |
![]() |
#2 |
Prophet
Join Date: Apr 2007
Location: Seattle, WA
Posts: 6,768
Donated: $40
![]() |
Getting it to build is a good start. The question is: does it work?
|
![]() |
![]() |
![]() |
#3 | |
Rookie
Join Date: Apr 2009
Posts: 13
![]() |
Quote:
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. ![]() |
|
![]() |
![]() |
![]() |
#4 |
Rookie
Join Date: Apr 2009
Posts: 13
![]() |
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 */ Code:
wc.cbWndExtra = sizeof(LONG_PTR); // 4 on 32bit, 8 on 64bit Code:
td = (term_data *)GetWindowLong(hWnd, 0); Code:
td = (term_data *)GetWindowLongPtr(hWnd, 0); Code:
SetWindowLong(hWnd, 0, (LONG)(my_td)); Code:
SetWindowLongPtr(hWnd, 0, (LONG_PTR)(my_td)); |
![]() |
![]() |
![]() |
#5 |
Knight
Join Date: Jan 2009
Posts: 657
![]() |
Well it didn't break anything on my 32 bit compile so I've borrowed the code.
![]()
__________________
Currently turning (Angband) Japanese. |
![]() |
![]() |
![]() |
#6 |
Rookie
Join Date: Apr 2009
Posts: 13
![]() |
Glad to help - if you're curious about the new version of the functions:
SetWindowLongPtr http://msdn.microsoft.com/en-us/libr...98(VS.85).aspx GetWindowLongPtr http://msdn.microsoft.com/en-us/libr...85(VS.85).aspx Looks like they were created to enable code that is compatible with 32-bit and 64-bit Windows. |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fundraiser 2008 | pav | Oook! | 9 | November 22, 2008 21:41 |
Something a bit different | Aknight | Variants | 22 | June 25, 2008 21:13 |
Getting Visual C++ 2008 Express Edition to compile Angband 3.0.9 | Orillian | Vanilla | 5 | February 10, 2008 09:23 |
Will we get rid of the 32 bit flag variables? | Bandobras | Vanilla | 18 | December 22, 2007 14:54 |
wall building? | Slick | Vanilla | 8 | November 1, 2007 01:29 |