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
➜ Shadowed declaration
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Metsuro
USA (389 posts) Bio
|
Date
| Sat 24 Dec 2005 11:03 PM (UTC) |
Message
| hometowns.c: In function `load_nations':
hometowns.c:328: warning: declaration of 'filename' shadows a previous local
hometowns.c:314: warning: shadowed declaration is here
{
FILE *list = NULL;
char filename[256]; - 314
/* load from nations list */
sprintf(filename, "%snations.lst", NATION_DIR);
if((list = fopen(filename, "r")) == NULL)
{
bug("load_nations(): cannot open %s for reading; aborting load", filename);
return;
}
top_nation = 0;
for( ; ; )
{
char *filename = feof(list) ? "$" : fread_string(list); - 328
not sure how to fix this or anything... |
Everything turns around in the end | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #1 on Sun 25 Dec 2005 01:29 AM (UTC) |
Message
| |
Posted by
| Samson
USA (683 posts) Bio
|
Date
| Reply #2 on Sun 25 Dec 2005 06:59 AM (UTC) |
Message
| That's because the "filename" variable is being declared twice. A shadow warning lets you know this was done since in some cases it can fubar the contents of the variable if you do that.
You should probably change the "filename" variable inside that for() loop to something else. I suggest "fname". This will avoid the possibility that you might end up overwriting something in memory that you don't want to.
( This also means I need to go back and check this code for errors since I'm the one hosting it :P ) | 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.
17,566 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top