Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old December 25, 2009, 09:34   #1
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,393
AnonymousHero is on a distinguished road
64-bit warning cleanliness patch

I've attached a little patch to cmd4.c to get it to compile cleanly on 64-bit (Ubuntu). The patch is against r1867.
Attached Files
File Type: txt 64-bit-clean.txt (1.4 KB, 349 views)
AnonymousHero is offline   Reply With Quote
Old December 25, 2009, 15:48   #2
konijn_
Hellband maintainer
 
konijn_'s Avatar
 
Join Date: Jul 2007
Location: New York, the Big Apple
Age: 46
Posts: 367
Donated: $120
konijn_ is on a distinguished road
Quote:
Originally Posted by AnonymousHero View Post
I've attached a little patch to cmd4.c to get it to compile cleanly on 64-bit (Ubuntu). The patch is against r1867.
Thank you. It would seem that there has to be a better way than declaring those numbers , no ?

T.
__________________
* Are you ready for something else ? Hellband 0.8.8 is out! *
konijn_ is offline   Reply With Quote
Old December 25, 2009, 18:08   #3
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,393
AnonymousHero is on a distinguished road
Yeah, it seems a bit excessive, but I couldn't think of a prettier (and portable) way to do it.
AnonymousHero is offline   Reply With Quote
Old December 25, 2009, 22:00   #4
zaimoni
Knight
 
zaimoni's Avatar
 
Join Date: Apr 2007
Posts: 590
zaimoni is on a distinguished road
Quote:
Originally Posted by konijn_ View Post
Thank you. It would seem that there has to be a better way than declaring those numbers , no ?

T.
One-line fix for C99 compilers (including GCC on Ubuntu):
Code:
-       int page = (int)vpage;
+        intptr_t page = (intptr_t)vpage);
Casting void* to intptr_t is always safe in C99. MSVC doesn't have stdint.h as it only implements C90, so the above isn't usable as-is.

Note that on sufficiently strict hardware, you die on the function call to do_cmd_option_aux anyway. If the hardware both requires special pointer registers to do anything, and faults instantly on an invalid pointer entering those registers: fatality during evaluating the arguments for the function call, if not in constructing the reference data structs to begin with.

So, if MSVC is to be supported, the given patch is indeed minimal.
__________________
Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011
zaimoni is offline   Reply With Quote
Old December 31, 2009, 07:04   #5
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 6,860
Donated: $40
Pete Mack will become famous soon enough
A reasonable thing to do is use size_t (or long), and to typedef size_t appropriately for windows on x86 and x64.

Also, can't you use 4L etc for long integers?
Pete Mack is offline   Reply With Quote
Old December 31, 2009, 10:16   #6
zaimoni
Knight
 
zaimoni's Avatar
 
Join Date: Apr 2007
Posts: 590
zaimoni is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
A reasonable thing to do is use size_t (or long), and to typedef size_t appropriately for windows on x86 and x64.
Code:
#include <stddef.h>
(which is already happening, and will typedef size_t even in C90) Unfortunately, it's implementation-defined in C99 whether size_t is the same as uintptr_t.

Quote:
Originally Posted by Pete Mack View Post
Also, can't you use 4L etc for long integers?
Yes. That's probably not what's frying 64-bit *NIX, however.
__________________
Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011
zaimoni is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Down to a single compiler warning. PaulBlay Development 9 May 20, 2009 17:20
Link warning Nick Development 12 April 17, 2009 01:36
Help with diving (warning: long) bebo Vanilla 6 January 22, 2009 03:23
Something a bit different Aknight Variants 22 June 25, 2008 21:13
Will we get rid of the 32 bit flag variables? Bandobras Vanilla 18 December 22, 2007 15:54


All times are GMT +1. The time now is 22:46.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.