Sign in to follow this  
Denisius

Compiling error

Recommended Posts

Denisius    122
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
Denisius    122
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
pinacolada    834
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this