Compile Dystopia, comm.o...errr....strcmp?

Posted by Justin Hayes on Wed 20 Aug 2003 06:30 PM — 6 posts, 21,912 views.

#0
I've compiled and run quite a few different codebases and by far the one with the most problems is probobly Dystopia. I even got CthulhuMud codebase running, which is quite a feat in my eyes. But anyhow, I'm using cygwin...maybe one day I'll switch over to true Unix instead of this cheap Diet Unix....but for now this is what I use. And I'm having a problem compiling dystopia. One of my problems was described in the thread
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2974

I got all that worked bout past the whole execinfo.h thing, then I got some different errors than him. Here are the errors I get.

$ make
gcc -c -Wall -g comm.c
comm.c:1581: parse error before numeric constant
comm.c:1581: warning: type defaults to `int' in declaration of `exit'
comm.c:1581: conflicting types for `exit'
/usr/include/stdlib.h:65: previous declaration of `exit'
comm.c:1581: warning: data definition has no type or storage class
comm.c: In function `nanny':
comm.c:2355: warning: implicit declaration of function `crypt'
comm.c:2355: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
comm.c:2363: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
comm.c:2565: warning: assignment makes pointer from integer without a cast
comm.c:2590: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
make: *** [comm.o] Error 1

I'm sure they would make perfect sense if I knew what it meant...and I'm sure it's an easy fix. But I just don't know HOW to fix it. If i could get some help with this, it would be GREAT. Thanks for anyone who may be able to help me.
Amended on Wed 20 Aug 2003 06:34 PM by Justin Hayes
#1

#if 0
/*
 * To do internal backtracs at crashes
 */
void iBacktrace(int iSignal)
{
  void *aTrace[10];
  char **tString;
  char buf[400]; //plenty
  int size, i, j, k;

  size = backtrace(aTrace, 10);
  printf("%s\n", (char *) aTrace[1]);
  tString = backtrace_symbols(aTrace, size);
  for (i = 0; i < size; i++)
  {
    bool found = FALSE;

    printf("%s\n", tString[i]);
    for (j = 0; tString[i][j] != '\0' && !found; j++)
    {
      if (tString[i][j] == '[')
      {
        j++;
        found = TRUE;
        for (k = j ; tString[i][j] != '\0' && tString[i][j] != ']'; j++)
        {
          buf[j-k] = tString[i][j];
        }
        buf[j-k] = '\0';
      }
    }
    printf("%s translates to : %s\n", buf, (char *) strtol(buf, NULL, 16));
  }
#endif
 exit(1); 
}



that's the section that i'm getting the error on...about the parsing and the exit thing.
Could someone explain to me what a parsing error is and the usual way to fix it?
Amended on Wed 20 Aug 2003 08:42 PM by Justin Hayes
Australia Forum Administrator #2
Ah yes, a parsing error. Well, if you read the whole book on C, and don't do everything in it, that is a parsing error. :)

In your case the endif looks a bit early. You know that "#if 0" means that everything from then on is ignored? Thus you can disregard whatever it is in that block. However the "#endif" turns the compiling back on.

It seems to me that the #endif should be a couple of lines further on, after the closing brace.



#3
*slaps himself in the forehead*

Now why didn't I catch that? Thanks so much. Wow....you dont know how long I've been looking at that code and how many different things I've tried.
#4
Okay, it compiled, got that same error as in the other thread and I ignored it and tried to boot up and I got a Segmentation Fault (core dumped), so I tried to change makefile to read dystopia.exe, tried to boot up again. Still same error. I entered gdb and ran the file, and backtraced and here's what I got.


$ gdb dystopia.exe
GNU gdb 2003-03-03-cvs (cygwin-special)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License,
welcome to change it and/or distribute copies of it under certai
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" f
This GDB was configured as "i686-pc-cygwin"...
(gdb) run
Starting program: /cygdrive/c/justin/random/mud/dystopia/area/dy

Program received signal SIGSEGV, Segmentation fault.
0x004d8537 in main (argc=1, argv=0x10030ec0) at comm.c:443
443             if (argv[2] && argv[2][0])
(gdb) bt
#0  0x004d8537 in main (argc=1, argv=0x10030ec0) at comm.c:443



Any idea's what's going on? the comm.c:443 is that referring to line 443? if so the only thing on that line is

if (argv[2] && argv[2][0])


Any ideas?



FOLLOWUP:
Commenting it out seemed to work fine, I'm not gonna open this up to the public, more like something for me to screw around with so i dont think it's gonna be an issue. Thanks again for your help Nick.
Amended on Thu 21 Aug 2003 12:31 AM by Justin Hayes
Australia Forum Administrator #5
argc is 1 which means you have one argument, and you are testing argument 2. That sounds a bit dodgy.