Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old June 16, 2010, 20:51   #31
ekolis
Knight
 
ekolis's Avatar
 
Join Date: Apr 2007
Location: Cincinnati, OH, USA
Age: 36
Posts: 911
ekolis is on a distinguished road
Send a message via AIM to ekolis Send a message via MSN to ekolis Send a message via Yahoo to ekolis
-1 == 255? Maybe in byte-land, but what if you're using multi-byte character sets (Unicode)?
__________________
You read the scroll labeled NOBIMUS UPSCOTI...
You are surrounded by a stasis field!
The tengu tries to teleport, but fails!
ekolis is offline   Reply With Quote
Old June 16, 2010, 20:55   #32
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 39
Posts: 1,516
d_m is on a distinguished road
In C, -1 has a two's complement binary representation as "1111111...." for whatever size integer you're talking about. If you cast it to (char) like Pete did, you end up with "11111111" in binary, which is 0xFF in hex, and 255 in decimal.

I think you're confused... in C the char datatype is always defined as one byte. If you want to represent a unicode character you'd use a different type. (char)-1 == (char)255 is invariant.
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old June 16, 2010, 22:20   #33
nppangband
NPPAngband Maintainer
 
Join Date: Dec 2008
Location: Stat Gain, Angband
Posts: 926
nppangband is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
What compiler are you using that complains about '\xff'? That is bog standard (char)-1
encoding.
Anyway, you are right, making it a #define constant is the right thing to do in any case.
LCC-Win 32, but I don't think that is the problem. The most current NPP is based on Angband 3.0.6, and I am dropping in Angband code from the latest release. With the re-writing of all the main.xxx files, the list of things that are #defined or #undef are completely different. I believe I am missing a #defined or there is an extra #undef that needs deleting. The fact that I am getting a compiler warning that bool is defined twice tells me I need to have to check this, file by file.

Does anyone have any recomendations for a good, free C compiler if LCC-WIN is the problem? My biggest limitation is that I am not a true programmer who could work off of a C:\ prompt. It would have to be a windows environment.....
nppangband is offline   Reply With Quote
Old June 16, 2010, 22:28   #34
ekolis
Knight
 
ekolis's Avatar
 
Join Date: Apr 2007
Location: Cincinnati, OH, USA
Age: 36
Posts: 911
ekolis is on a distinguished road
Send a message via AIM to ekolis Send a message via MSN to ekolis Send a message via Yahoo to ekolis
If you use mingw/msys, you can just use the makefiles out of the box as if you were in Linux... if you're looking for an actual IDE, there's Visual C++ Express; I successfully got angband to compile in it after a bit of finagling, and I can send you the project files necessary if you'd like!
__________________
You read the scroll labeled NOBIMUS UPSCOTI...
You are surrounded by a stasis field!
The tengu tries to teleport, but fails!
ekolis is offline   Reply With Quote
Old June 16, 2010, 22:33   #35
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,391
Donated: $40
Pete Mack is on a distinguished road
@jeff--
just about everyone uses gcc (MINGW on Windows) for compiling angband, though lcc is supposed to work too. I agree that redefines of bool are a much worse sign. (And why there's a #define for bool in the first place is beyond me. It's a standard data type in C99 and later.)
Pete Mack is offline   Reply With Quote
Old June 16, 2010, 23:04   #36
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 39
Posts: 1,516
d_m is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
@jeff--
(And why there's a #define for bool in the first place is beyond me. It's a standard data type in C99 and later.)
Current Angband coding guidelines target C89, so C99's bool is not available.

It's worth asking Takk about this, I think.
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old June 17, 2010, 01:40   #37
nppangband
NPPAngband Maintainer
 
Join Date: Dec 2008
Location: Stat Gain, Angband
Posts: 926
nppangband is on a distinguished road
Quote:
Originally Posted by d_m View Post
Current Angband coding guidelines target C89, so C99's bool is not available.

It's worth asking Takk about this, I think.
Line 155 of h-basic.h has this:

/* C++ defines its own bool type, so we hack around it */
#undef bool
#define bool bool_hack

Then a couple lines later, there is this:

/*
* Use a real bool type where possible
*/
#ifdef HAVE_STDBOOL_H

#include <stdbool.h>

#define TRUE true
#define FALSE false

#else

/* Use a char otherwise */
typedef char bool;

and around line 50 of the same file, there is this....about STDBOOL...

/*
* Using C99, assume we have stdint and stdbool
*/
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define HAVE_STDINT_H
# define HAVE_STDBOOL_H
# endif

and at that point my little brain explodes..... I have no clue what is going on there. I assume it is an attempt to standardize the definition of bool for certain operating systems and compilers. But I doubt I could even understand it if somebody tried to explain it to me.
nppangband is offline   Reply With Quote
Old June 17, 2010, 01:56   #38
nppangband
NPPAngband Maintainer
 
Join Date: Dec 2008
Location: Stat Gain, Angband
Posts: 926
nppangband is on a distinguished road
OK, gonig back to basics, what files are needed to compile Angband version 3.1.2 v2 on windows. If I get that going with LCC_win32, I can see what warnings come up.

I assume:

angband.rc

in the src directory:
the files attack.c through load.c. Is load-old.c needed?
main-win.c
files option.c through z-virt.c

now, for the src/subdirectories:
doc - nothing?
gtk - nothing?
lcc - nothing?
monster - melee1, melee2, monster1, monster 2
nds - nothing?
object - identify.c through randart.c
osx - nothing
player - calcs.c, timed.c, and util.c (note here LCC_win fails becaule util.c has the same name as hte file in the src directory. All files have to have different names regardless of which directory they are in)
tests - nothing? There are three files, smaple.c, z-file.c, and z-tets.c. Are these experimental, or should they be included?
win - readdib.c

I would experiment with this, but the feature to delete a *.c file from a makefile in LCC_win is broken. I can add them, but if I need to delete a file I have to start all over.
nppangband is offline   Reply With Quote
Old June 17, 2010, 02:17   #39
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,391
Donated: $40
Pete Mack is on a distinguished road
Quote:
Originally Posted by d_m View Post
Current Angband coding guidelines target C89, so C99's bool is not available.

It's worth asking Takk about this, I think.
Yep. There is no reason to code to a 20 year old standard when a 10 year old standard is available.
Pete Mack is offline   Reply With Quote
Old June 27, 2010, 12:39   #40
nppangband
NPPAngband Maintainer
 
Join Date: Dec 2008
Location: Stat Gain, Angband
Posts: 926
nppangband is on a distinguished road
Quote:
Originally Posted by d_m View Post
'\xff' is (or should be) a character constant, kind of like '\n' or '\011'. In this case it's the number 255, aka 0377 in octal notation, aka 0xFF in hex notation.
I understand the problem now. It isn't the constant, but the fact that the Angband code places that code into a signed char variable. It was warning me that I was putting a value of 255 into a variable with a range of -127 to 128. When I changed the varible key in the structure ui_event_data (ui-event.h) to an unsigned character my compiler stopped complaining. Is that variable intended to hold values from -127 to -1?
nppangband 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
Trying to understand Ranger playing mechanics dormouse Vanilla 5 December 15, 2009 12:43
Angband Code Interface to GUI meeshoo Vanilla 50 February 3, 2009 18:18
I finally understand how diving quicker can be "safer" Wraitheist Vanilla 13 September 19, 2008 18:25
strange C code in Angband (am I reading this right?) will_asher Idle chatter 3 February 4, 2008 10:07
Angband source branches vs trac ctate Vanilla 1 July 14, 2007 12:43


All times are GMT +1. The time now is 09:20.


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