Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, DotBot, Yandex

Members: 0
Guests: 16
Stats
Files
Topics
Posts
Members
Newest Member
481
3,735
19,370
618
Micheal64X
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » General Discussions » Template functions and compil...
Forum Rules | Mark all | Recent Posts

Template functions and compiler warnings
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 6, 2005, 12:25 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Just for the hell of it, I was going over my code with the -Wswitch-default flag and have run into one warning I cannot resolve:

mud_prog.h: In function 'void mprog_file_read(N*, char*)':
mud_prog.h:173: warning: switch missing default case


Yes, this is a c++ templated function, which looks like:

template< class N > void mprog_file_read( N *prog_target, char *f )
{
   mud_prog_data *mprg = NULL;
   char MUDProgfile[256];
   FILE *progfile;
   char letter;

   snprintf( MUDProgfile, 256, "%s%s", PROG_DIR, f );

   if( !( progfile = fopen( MUDProgfile, "r" ) ) )
   {
      bug( "%s: couldn't open mudprog file", __FUNCTION__ );
      return;
   }

   for( ; ; )
   {
      letter = fread_letter( progfile );

      if( letter == '|' )
         break;

      if( letter != '>' )
      {
         bug( "%s: MUDPROG char", __FUNCTION__ );
         break;
      }

      mprg = new mud_prog_data;
      mprg->type = mprog_name_to_type( fread_word( progfile ) );
      switch( mprg->type )
      {
         default:
            mprg->arglist = fread_string( progfile );
            mprg->comlist = fread_string( progfile );
            mprg->fileprog = true;
            prog_target->progtypes.set( mprg->type );
            prog_target->mudprogs.push_back( mprg );
            break;

         case ERROR_PROG:
            bug( "%s: mudprog file type error", __FUNCTION__ );
            deleteptr( mprg );
            continue;

         case IN_FILE_PROG:
            bug( "%s: Nested file programs are not allowed.", __FUNCTION__ );
            deleteptr( mprg );
            continue;
      }
   }
   FCLOSE( progfile );
   return;
}


Is there any way to silence the warning properly since it's pretty obvious there *IS* a default case?
       
Post is unread #2 Sep 7, 2005, 8:04 pm   Last edited Sep 7, 2005, 8:06 pm by Noplex
Go to the top of the page
Go to the bottom of the page

Noplex
Apprentice
GroupMembers
Posts62
JoinedAug 30, 2005

That's rather odd that its doing that. Have you tried moving the default case to the bottom of the switch statement?

Isn't that line suppose to be 255 (1 character for /0)?
snprintf( MUDProgfile, 256, "%s%s", PROG_DIR, f );

Or does it add it the end automagically?
       
Pages:<< prev 1 next >>