Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old April 22, 2009, 12:07   #1
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Changeset 1372

This line causes a compiler error (well, three errors to be precise).

Code:
u32b dupcheck[z_info->e_max];
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'dupcheck' : unknown size

[EDITx2] It compiles with Dev-C++ (but not with VC++?). Going to check some more things ...

[EDITx3] Pretty sure it should be the following code (but I have an unrelated problem that is Angband/65 only. :-(

Code:
	u32b *dupcheck;
	dupcheck = C_ZNEW(z_info->e_max, u32b);
__________________
Currently turning (Angband) Japanese.

Last edited by PaulBlay; April 22, 2009 at 12:36.
PaulBlay is offline   Reply With Quote
Old April 22, 2009, 15:38   #2
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,379
Donated: $40
Pete Mack is on a distinguished road
That array initialization is a C99-ism. Your fix will solve it, if you really want to. Don't forget to free dupcheck when you are done with it.
Pete Mack is offline   Reply With Quote
Old April 22, 2009, 17:33   #3
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by Pete Mack View Post
That array initialization is a C99-ism. Your fix will solve it, if you really want to. Don't forget to free dupcheck when you are done with it.
This causes me a problem. I wrote that code, and it compiled cleanly on gcc with no warnings whatsoever. But I know that Angband is supposed to be C89-compliant, because ajps and others often correct my code to C89 standards. Is there a way that I can tell gcc to be strict about C89?

@paul: thanks for the tip - I'll correct it tonight. I didn't think you had to use C_ZNEW if you were throwing the array away at the end of the function (which we are in this case).
Magnate is offline   Reply With Quote
Old April 22, 2009, 17:39   #4
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by Magnate View Post
This causes me a problem. I wrote that code, and it compiled cleanly on gcc with no warnings whatsoever. But I know that Angband is supposed to be C89-compliant, because ajps and others often correct my code to C89 standards. Is there a way that I can tell gcc to be strict about C89?
Come to think of it, since I invoke gcc via make, shouldn't whatever does this go into the Angband makefiles?
Magnate is offline   Reply With Quote
Old April 22, 2009, 18:39   #5
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,936
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by Magnate View Post
Come to think of it, since I invoke gcc via make, shouldn't whatever does this go into the Angband makefiles?
I think the problem here is that the autoconf buildsystem don't have the same flags as Makefile.std does, the latter of which I use for most development. I'll have a look into transferring the flags across.
__________________
takkaria whispers something about options. -more-
takkaria is offline   Reply With Quote
Old April 22, 2009, 21:36   #6
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Fixed in r1374. Thanks Paul.
Magnate is offline   Reply With Quote
Old April 23, 2009, 00:11   #7
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 54
Posts: 7,832
Donated: $60
Nick is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
That array initialization is a C99-ism. Your fix will solve it, if you really want to. Don't forget to free dupcheck when you are done with it.
Ah, that explains why stuff like that didn't compile cleanly for me a while ago (probably for WinCE in eVC++). Keep it up, Pete - I'll be a programmer one day.
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old April 23, 2009, 05:27   #8
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,379
Donated: $40
Pete Mack is on a distinguished road
Quote:
Originally Posted by Magnate View Post
This causes me a problem. I wrote that code, and it compiled cleanly on gcc with no warnings whatsoever. But I know that Angband is supposed to be C89-compliant, because ajps and others often correct my code to C89 standards. Is there a way that I can tell gcc to be strict about C89?
From http://gcc.gnu.org/onlinedocs/gcc-3....Standards.html
Possibilities include:

-std=c89 or -std=iso9899:1990

Don't apply this uniformly on the OSX build, because main-crb.c requires std=g99, as well as objective C.
Pete Mack 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


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


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