Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Frobozz
(75 posts) bio
|
| Date |
Sat 20 Nov 2004 09:29 PM (UTC) [ quote
] |
| Message |
make -s smaug
Compiling o/act_comm.o....
cc1: warnings being treated as errors
act_comm.c: In function `do_say_to_char':
act_comm.c:3072: warning: declaration of `last_char' shadows global declaration
make[1]: *** [o/act_comm.o] Error 1
make: *** [all] Error 2
----> not sure what this error means | top |
|
| Posted by |
Frobozz
(75 posts) bio
|
| Date |
Reply #1 on Sat 20 Nov 2004 09:31 PM (UTC) [ quote
] |
| Message |
void do_say_to_char( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH], last_char; ( <---- This is the error, I think... not sure)
char buf[MAX_STRING_LENGTH];
CHAR_DATA *vch;
CHAR_DATA *victim;
EXT_BV actflags;
int arglen; | top |
|
| Posted by |
David Haley
USA (3,881 posts) bio
Moderator |
| Date |
Reply #2 on Sat 20 Nov 2004 09:55 PM (UTC) [ quote
] |
| Message |
Variable shadowing is when a local variable has the same name as a global variable, so if you use the variable name, it will refer to the local one and not the global one.
In your case, the global variable is a global CHAR_DATA * last_char, I believe, which is the tail of the linked list of characters.
Hence the importance of prefixing or otherwise representing global variables one way or another, to avoid conflicts such as this. I typically use 'g' as a prefix e.g. gLastChar. Then again, I try to avoid global variables whenever possible, because they are quite bad stylistically except in certain very specific vases.
To solve your problem, you should just use a different name for the local variable, e.g. lastC or lastChar. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
1,291 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )