When trying to compile SWR on Cygwin, I keep getting the following error, no matter what I've been told by anyone I know.. :
make swreality
make[1]: Entering directory `/home/Adam1/swr/src'
gcc -c -g3 -Wall save.c
save.c: In function `load_char_obj':
save.c:913: warning: suggest explicit braces to avoid ambiguous `else'
save.c: In function `load_corpses':
save.c:2055: warning: assignment from incompatible pointer type
save.c:2057: dereferencing pointer to incomplete type
save.c:2059: dereferencing pointer to incomplete type
make[1]: *** [save.o] Error 1
make[1]: Leaving directory `/home/Adam1/swr/src'
make: *** [all] Error 2
If anyone can help, thanks a lot!
It is hard to debug from just the error messages. Can you post the 10 lines preceding line 2059 in save.c, and indicate which are lines 2055, 2057 and 2059?
void load_corpses( void )
{
DIR *dp;
struct direct *de;
extern FILE *fpArea;
extern char strArea[MAX_INPUT_LENGTH];
extern int falling;
if ( !(dp = opendir(CORPSE_DIR)) )
{
bug( "Load_corpses: can't open CORPSE_DIR", 0);
perror(CORPSE_DIR);
return;
}
falling = 1; /* Arbitrary, must be >0 though. */
while ( (de = readdir(dp)) != NULL )
{
if ( de->d_name[0] != '.' )
{
sprintf(strArea, "%s%s", CORPSE_DIR, de->d_name );
fprintf(stderr, "Corpse -> %s\n", strArea);
if ( !(fpArea = fopen(strArea, "r")) )
{
perror(strArea);
continue;
}
for ( ; ; )
{
char letter;
char *word;
letter = fread_letter( fpArea );
if ( letter == '*' )
{
fread_to_eol(fpArea);
continue;
}
if ( letter != '#' )
{
bug( "Load_corpses: # not found.", 0 );
break;
}
word = fread_word( fpArea );
if ( !str_cmp(word, "CORPSE" ) )
fread_obj( NULL, fpArea, OS_CORPSE );
else if ( !str_cmp(word, "OBJECT" ) )
fread_obj( NULL, fpArea, OS_CARRY );
else if ( !str_cmp( word, "END" ) )
break;
else
{
bug( "Load_corpses: bad section.", 0 );
break;
}
}
fclose(fpArea);
}
}
fpArea = NULL;
strcpy(strArea, "$");
closedir(dp);
falling = 0;
return;
}
Line 2055: while ( (de = readdir(dp)) != NULL )
Line 2057: if ( de->d_name[0] != '.' )
Line 2059: sprintf(strArea, "%s%s", CORPSE_DIR, de->d_name );
Do you have this line near the start of save.c, without any #ifdef around it?
If not, put it there. If there is an #ifdef remove it. ie, change:
#ifndef WIN32
#include <dirent.h>
#endif
to
Ack.. tried that, and still got the same error. Thanks anyway Nick!
I got it to compile under Cygwin by adding one line. This is what the start of save.c looks like for me ...
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#include "mud.h"
#define direct dirent // add this line
Nick, you are a genious! I been scrounging over these forums for a fix, and you had it!