Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old February 19, 2009, 13:39   #1
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Compiling using Makefile.nmake

I'm trying to compile Angband 3.1.0 using Visual Studio 2008 and Makefile.nmake

It seems that there are a lot of .c files in subdirectories with lines like ...

#include "angband.h"

that all need to be changed to

#include "../angband.h"

in order for it to compile. A quick look at the SVN version shows that the same lines are present (without any ../ ). Does this mean the Makefile.nmake needs to be changed or is there some command line setting or something I'm missing?
PaulBlay is offline   Reply With Quote
Old February 19, 2009, 15:46   #2
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Trying again with the SVN source.

death.c
The line
Code:
 	const region area = { 51, 2, 0, menu->count };
is not accepted where it (now) is by the compiler. I get the error
missing ; before const

If I change the last parameter to 7 and put it back where it was then it will compile.
Code:
void death_screen(void)
{
	menu_type *menu;
	const char cmd_keys[] = { ARROW_LEFT, ARROW_RIGHT, '\0' };
	const region area = { 51, 2, 0, 7 };
PaulBlay is offline   Reply With Quote
Old February 19, 2009, 16:03   #3
PowerDiver
Prophet
 
Join Date: Mar 2008
Posts: 2,712
PowerDiver is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
#include "angband.h"

that all need to be changed to

#include "../angband.h"
The configure script ought to set up the makefile to call the compiler with some flags -Isomedirectory, and angband.h needs to be in one of the dirs indicated by one of those.
PowerDiver is offline   Reply With Quote
Old February 19, 2009, 16:12   #4
PowerDiver
Prophet
 
Join Date: Mar 2008
Posts: 2,712
PowerDiver is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
Trying again with the SVN source.

death.c
The line
Code:
 	const region area = { 51, 2, 0, menu->count };
is not accepted where it (now) is by the compiler. I get the error
missing ; before const

If I change the last parameter to 7 and put it back where it was then it will compile.
Code:
void death_screen(void)
{
	menu_type *menu;
	const char cmd_keys[] = { ARROW_LEFT, ARROW_RIGHT, '\0' };
	const region area = { 51, 2, 0, 7 };
The compiler wants to set a constant structure for the area, at compile time. If menu->count is not a const, it cannot do that.

The error message seems a little strange unless macros are involved. You should also check that you did not somehow remove the ; on the cmd_keys line.
PowerDiver is offline   Reply With Quote
Old February 19, 2009, 16:23   #5
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by PowerDiver View Post
The configure script ought to set up the makefile to call the compiler with some flags -Isomedirectory, and angband.h needs to be in one of the dirs indicated by one of those.
http://trac.rephial.org/browser/trun...Makefile.nmake

OK, the Makefile.nmake file in the SVN needs to have line 22 changed to
Code:
CFLAGS = $(CFLAGS) /O2 /Os /Gs /I.
and line 24 needs to be changed to
Code:
CFLAGS = $(CFLAGS) /Od /Zi /I.
PaulBlay is offline   Reply With Quote
Old February 19, 2009, 16:29   #6
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,654
Donated: $40
Pete Mack is on a distinguished road
Having the menu region declared way down in the procedure body requires C99, not C90 (or iso9899)

I don't recall what the right option to cl.exe is to enable this.

(It has nothing to do with constness, except insofar as you can't have good constness in c90 proper without running into used-before-set problems.)
Pete Mack is offline   Reply With Quote
Old February 19, 2009, 16:53   #7
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
Having the menu region declared way down in the procedure body requires C99, not C90 (or iso9899)

I don't recall what the right option to cl.exe is to enable this.
I get the impression that Visual Studios 2008 only partially supports C99 so there might not be an option for that. I suppose the point here is that it probably isn't good code for something that needs to work on a wide variety of platforms compiled by many different compilers.

[EDIT]/Ze enables extensions - but that is supposed to be on by default.
[EDIT*2]Yes, I checked and /Ze doesn't change anything.

Last edited by PaulBlay; February 19, 2009 at 17:27.
PaulBlay is offline   Reply With Quote
Old February 19, 2009, 17:17   #8
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Same problem with init2.c line 735 in init_r_info

The 'int i' should be at the start of the function.

With that corrected I get no more compile errors with Visual Studios 2008 (nmake). I get a ton of warning messages though

[EDIT]OK, looking at compiler warnings ...
attack.c(592) : warning C4244: '+=' : conversion from 's32b' to 'byte', possible loss of data
Code:
m_ptr->confused += 10 + randint0(p_ptr->lev) / 5;
I guess 'confused' could suffer from overflow if there are 10 successive successful hits from a level 100 character. Not very likely to happen. ;-)

The following code stops the compiler warning for Visual Studio 2008 (don't know if it will break it for any other compiler though)

Code:
/* Suppresses compiler warning. Conversion is safe given player max level */
m_ptr->confused += 10 + (byte)randint0(p_ptr->lev) / 5;
birth.c(1667) : warning C4090: 'function' : different 'const' qualifiers
from
Code:
mem_free(race_choices);
According to a page Google found there isn't any real fix for that but the warning can be avoided by
Code:
mem_free((void *)race_choices);
Again I don't know if that is wise.

There are a lot of 'security' warnings. Unfortunately the suggestions given by Visual Studio seem to be Microsoft specific. I suppose equivalent solutions could be found / written if really necessary.

death.c(97) : warning C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\time.inl(88) : see declaration of 'ctime'

Back to more serious looking warnings

util.c(2348) : warning C4550: expression evaluates to a function which is missing an argument list
Referring to
Code:
keypress_h = askfor_aux_keypress;
The function askfor_aux_keypress is given with
Code:
bool askfor_aux_keypress(char *buf, size_t buflen, size_t *curs, size_t *len, char keypress, bool firsttime)

Last edited by PaulBlay; February 19, 2009 at 19:46.
PaulBlay is offline   Reply With Quote
Old February 20, 2009, 07:37   #9
zaimoni
Knight
 
zaimoni's Avatar
 
Join Date: Apr 2007
Posts: 590
zaimoni is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
Back to more serious looking warnings

util.c(2348) : warning C4550: expression evaluates to a function which is missing an argument list
Referring to
Code:
keypress_h = askfor_aux_keypress;
The function askfor_aux_keypress is given with
Code:
bool askfor_aux_keypress(char *buf, size_t buflen, size_t *curs, size_t *len, char keypress, bool firsttime)
MS is bungling the ISO-required promotion of a naked function name to a function pointer.

What MS wants

Code:
keypress_h = &askfor_aux_keypress;
is accepted by MingW32 4.2.1 (the & is a no-op).
zaimoni is offline   Reply With Quote
Old February 20, 2009, 08:01   #10
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by zaimoni View Post
MS is bungling the ISO-required promotion of a naked function name to a function pointer.

What MS wants

Code:
keypress_h = &askfor_aux_keypress;
is accepted by MingW32 4.2.1 (the & is a no-op).
Thanks. That makes more sense to me anyway.
PaulBlay 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
compiling in VC6 NeoWizard Vanilla 1 January 16, 2009 02:10
Compiling in Linux trickypig Vanilla 6 November 16, 2008 15:26
Compiling Issues Gregian Vanilla 13 July 2, 2008 14:35
Compiling 3.0.9b under SuSE 9.3 ... TJA Vanilla 14 May 12, 2008 21:17
Compiling ToME TJA Variants 6 October 31, 2007 12:32


All times are GMT +1. The time now is 21:39.


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