Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ odd error
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Sat 20 Nov 2004 09:29 PM (UTC) |
| 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) |
| 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
|
| Date
| Reply #2 on Sat 20 Nov 2004 09:55 PM (UTC) |
| 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.
12,778 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top