Register forum user name Search FAQ

Gammon Forum

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 ➜ do_who warnings

do_who warnings

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Ithildin   USA  (262 posts)  Bio
Date Tue 30 May 2006 02:24 AM (UTC)
Message
I'm switching up the do_who code to look a little better. I'm using smaugfuss 1.7 When I compiled I got these two errors and I don't know how to fix them:

make -s smaug
  Compiling o/act_info.o....
act_info.c: In function `do_who':
act_info.c:2960: warning: format not a string literal and no format arguments
act_info.c:2984: warning: format not a string literal and no format arguments
make[1]: *** [o/act_info.o] Error 1
make: *** [all] Error 2


Here's the two lines:

for ( cur_who = first_imm; cur_who; cur_who = next_who )
    {
      if ( !ch )
        fprintf( whoout, cur_who->text );  <--------Offending line
      else
        send_to_pager( cur_who->text, ch );
      next_who = cur_who->next;
      DISPOSE( cur_who->text );
      DISPOSE( cur_who );
	  } 


and

for ( cur_who = first_mortal; cur_who; cur_who = next_who )
    {
      if ( !ch )
        fprintf( whoout, cur_who->text ); <-------------Second Offending Line
      else
        send_to_pager( cur_who->text, ch );
      next_who = cur_who->next;
      DISPOSE( cur_who->text );
      DISPOSE( cur_who ); 
    } 


What's wrong with those two lines?
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #1 on Tue 30 May 2006 04:57 AM (UTC)
Message
got it fixed.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Tue 30 May 2006 05:29 AM (UTC)
Message
For reference, the problem is that it wants a string explaining the format, not a straight string. It's a little odd that it's requiring that, even if it makes sense in some situations. (It means that it would, for example, incorrect warn about a format string being contained in a runtime-defined string.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 30 May 2006 05:38 AM (UTC)

Amended on Tue 30 May 2006 05:39 AM (UTC) by Nick Gammon

Message
Quote:

When I compiled I got these two errors ...


These are warnings, not errors.

I think it wants to check the arguments for you. For example, if you did:


int i;
fprintf (whoout, "%s", i );


Then it can say that "i" is an integer and not a string.

In your case you are supplying a single argument, so it is wondering why you are using fprintf in the first place.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Tue 30 May 2006 05:47 AM (UTC)
Message
Ah, you're right, it probably wouldn't complain if you gave it arguments with a runtime string as a format specifier.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #5 on Tue 30 May 2006 07:42 PM (UTC)
Message
Yea, that's what it was. I was missing the "%s"
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.


18,415 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.