Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old May 19, 2009, 18:51   #1
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Down to a single compiler warning.

Down to a single compiler warning, with VC++ at /W4 when compiling Angband/65. It's a pity that there are some real, game-crashing bugs, but hey! Only one compiler warning

Anyway, that warning is

warning C4550: expression evaluates to a function which is missing an argument list

for
Code:
		keypress_h = askfor_aux_keypress;
Exactly the same warning is given when compiling Vanilla Angband (along with 1306 other warnings). I haven't the foggiest idea what could, or should, be done to placate Visual Studio in that case (I tried stuff earlier, and made 'bad things' happen )
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old May 19, 2009, 19:07   #2
Atarlost
Swordsman
 
Join Date: Apr 2007
Posts: 441
Atarlost is on a distinguished road
Does it show in other compilers? It may just be that the people who wrote VCC think you shouldn't be trusted with function pointers.
__________________
One Ring to rule them all. One Ring to bind them.
One Ring to bring them all and in the darkness interrupt the movie.
Atarlost is offline   Reply With Quote
Old May 19, 2009, 19:14   #3
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by Atarlost View Post
Does it show in other compilers?
It doesn't on whatever-the-heck gets used in Linux (gcc, I guess).

Quote:
Originally Posted by Atarlost View Post
It may just be that the people who wrote VCC think you shouldn't be trusted with function pointers.
Well, maybe, but there are plenty of other superficially similar appearing lines which aren't complained about by VCC.

Code:
ang_sort_comp = ang_sort_comp_hook_longs;
for instance.

I can only assume it may have something to do with the weird looking way keypress_h is declared (in the middle of declaring askfor_aux).

Code:
extern bool askfor_aux(char *buf, size_t len, bool keypress_h(char *, size_t, size_t *, size_t *, char, bool));
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old May 19, 2009, 19:15   #4
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by Atarlost View Post
It may just be that the people who wrote VCC think you shouldn't be trusted with function pointers.
Alternative punchline:

Hey, I don't think I should be trusted with function pointers.
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old May 19, 2009, 22:39   #5
LanceDiamond
Rookie
 
Join Date: Apr 2009
Posts: 13
LanceDiamond is on a distinguished road
If you change it to:


Code:
(bool *) keypress_h = (bool *) askfor_aux_keypress;
I think you'll shut VC up and it shouldn't hurt anything. I think VC is trying to tell you it's not sure if you're trying to call the function or trying to assign the pointer value.
LanceDiamond is offline   Reply With Quote
Old May 20, 2009, 02:37   #6
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by LanceDiamond View Post
I think you'll shut VC up and it shouldn't hurt anything. I think VC is trying to tell you it's not sure if you're trying to call the function or trying to assign the pointer value.
Well the good news is that it got rid of the original warning. The bad news is that it produced three more warnings it its place.

Code:
warning C4054: 'type cast' : from function pointer 'bool_hack (__cdecl *)(char *,size_t,size_t *,size_t *,char,bool_hack)' to data pointer 'bool_hack *'
warning C4054: 'type cast' : from function pointer 'bool_hack (__cdecl *)(char *,size_t,size_t *,size_t *,char,bool_hack)' to data pointer 'bool_hack *'
warning C4213: nonstandard extension used : cast on l-value
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old May 20, 2009, 04:48   #7
Atarlost
Swordsman
 
Join Date: Apr 2007
Posts: 441
Atarlost is on a distinguished road
I'd worry about that third one. It might be an actual error in some compilers. Don't cast the lvalue at all. Maybe cast the rvalue to a void*?
__________________
One Ring to rule them all. One Ring to bind them.
One Ring to bring them all and in the darkness interrupt the movie.
Atarlost is offline   Reply With Quote
Old May 20, 2009, 06:26   #8
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 6,768
Donated: $40
Pete Mack will become famous soon enough
The only thing I can think of is that you are overwriting a function argument rather than a local variable. But I don't see why that should make any difference. In any case, that is an absolutely hideous function. What a crazy, 1980's way to turn '*' into a random name.
Pete Mack is offline   Reply With Quote
Old May 20, 2009, 06:41   #9
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
In any case, that is an absolutely hideous function. What a crazy, 1980's way to turn '*' into a random name.
You're referring to the first or the second version?

'Cuz the first one's Vanilla Angand and the second one's by Atarlost.
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old May 20, 2009, 17:20   #10
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Well I got the answer (from a C programming forum).

In externs.h
Code:
extern bool askfor_aux(char *buf, size_t len, bool (*keypress_h)(char *, size_t, size_t *, size_t *, char, bool));
In util.c
Code:
bool askfor_aux(char *buf, size_t len, bool (*keypress_h)(char *, size_t, size_t *, size_t *, char, bool))
Now compiles with no compiler warnings and the program still works.
__________________
Currently turning (Angband) Japanese.
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
VC++ compiler help wanted. PaulBlay Development 6 April 24, 2009 16:29
Link warning Nick Development 12 April 17, 2009 01:36
Help with diving (warning: long) bebo Vanilla 6 January 22, 2009 02:23


All times are GMT +1. The time now is 00:44.


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