Jump to content
  • Advertisement
Sign in to follow this  
Denisius

Compiling error

This topic is 3893 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When i try to compile using GCC, i get this error:
Quote:
comm.c: In function 'do_crashguard': comm.c:4061: error: 'buf7' undeclared (first use in this function) comm.c:4061: error: (Each undeclared identifier is reported only once comm.c:4061: error: for each function it appears in.) make[1]: *** [o/comm.o] Error 1 make: *** [all] Error 2
And here is the do_crashguard function:
Quote:
void do_crashguard( ) { FILE *fp; DESCRIPTOR_DATA *d, *d_next; char buf[100], buf2[100], buf3[100], buf4[100]; fp = fopen( COPYOVER_FILE, "w" ); if( !fp ) { log_printf( "Could not write to copyover file: %s", COPYOVER_FILE ); perror( "do_copyover:fopen" ); return; } sprintf( buf, "\r\n[INFO] CRASHGUARD - please remain seated!\r\n\a" ); for( d = first_descriptor; d; d = d_next ) { CHAR_DATA *och = CH( d ); d_next = d->next; if( !d->character || d->connected < 0 ) { write_to_descriptor( d->descriptor, "\n\rSorry, we are rebooting." " Come back in a few minutes.\n\r", 0 ); close_socket( d, FALSE ); } else { fprintf( fp, "%d %s %s\n", d->descriptor, och->name, d->host ); save_char_obj( och ); write_to_descriptor( d->descriptor, buf, 0 ); } } fprintf( fp, "-1\n" ); fclose( fp );

Share this post


Link to post
Share on other sites
Advertisement
The error is pretty much what it says- you're trying to use something called 'buf7' without declaring it. Which line of the code is line 4061?

Share this post


Link to post
Share on other sites
Sorry, that was not the full function. Here it is:
Quote:

void do_crashguard( )
{
FILE *fp;
DESCRIPTOR_DATA *d, *d_next;
char buf[100], buf2[100], buf3[100], buf4[100];
fp = fopen( COPYOVER_FILE, "w" );
if( !fp )
{
log_printf( "Could not write to copyover file: %s", COPYOVER_FILE );
perror( "do_copyover:fopen" );
return;
}
sprintf( buf, "\r\n[INFO] CRASHGUARD - please remain seated!\r\n\a" );
for( d = first_descriptor; d; d = d_next )
{
CHAR_DATA *och = CH( d );
d_next = d->next;
if( !d->character || d->connected < 0 )
{
write_to_descriptor( d->descriptor, "\n\rSorry, we are rebooting." " Come back in a few minutes.\n\r", 0 );
close_socket( d, FALSE );
}
else
{
fprintf( fp, "%d %s %s\n", d->descriptor, och->name, d->host );
save_char_obj( och );
write_to_descriptor( d->descriptor, buf, 0 );
}
}
fprintf( fp, "-1\n" );
fclose( fp );
#ifdef I3
if( I3_is_connected( ) )
{
I3_savechanlist( );
I3_savemudlist( );
I3_savehistory( );
}
#endif
#ifdef IMC
imc_hotboot( );
#endif
fclose( fpReserve );
fclose( fpLOG );
fpReserve = NULL;
fpLOG = NULL;
sprintf( buf, "%d", port );
sprintf( buf2, "%d", control );
#ifdef I3
sprintf( buf3, "%d", I3_socket );
#else
strcpy( buf3, "-1" );
#endif
#ifdef IMC
if( this_imcmud )
snprintf( buf4, 100, "%d", this_imcmud->desc );
else
strncpy( buf4, "-1", 100 );
#else
strncpy( buf7, "-1", 100 );
#endif
execl( EXE_FILE, "rmexe", buf, "copyover", buf2, buf3, buf4, ( char * )NULL );
perror( "do_copyover: execl" );
if( ( fpReserve = fopen( NULL_FILE, "r" ) ) == NULL )
{
perror( NULL_FILE );
exit( 1 );
}
if( ( fpLOG = fopen( NULL_FILE, "r" ) ) == NULL )
{
perror( NULL_FILE );
exit( 1 );
}

}



And here is the line 4061:
Quote:

strncpy( buf7, "-1", 100 );

Share this post


Link to post
Share on other sites
I'm guessing you didn't write this code?

Looking at it, I think it was just a typo, and the person meant to write "buf4" instead of "buf7". (Otherwise, buf4 might be used without being assigned). So, try changing "buf7" to "buf4".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!