[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  odd error

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

odd error

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Frobozz   (75 posts)  [Biography] 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
[Go to top] top

Posted by Frobozz   (75 posts)  [Biography] 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;
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] 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
[Go to top] 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]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]