0

So recently, I was messing around with the source for Nethack, a rather old game. I used this guide to help me get started: Compiling - Wikihack.

To test, I first compiled the original source code. A few tweaks later, I was able to get it running without any problems. Next, I edited the source a little and added two sample monsters, based on existing monsters. The game compiled without any problems, and my test monsters were present in-game.

After that, I tried tweaking the monsters a little and recompiled. But none of my tweaks showed up, for some reason. I decided to delete everything and start from scratch, once again rebuilding the original source, no modifications done yet. And now suddenly, I'm getting errors, referencing the test monsters that are missing.

How is this possible? I double-checked that this test monster is not in the source code (and why should it be? It's the original source). My only explanation is that the compiler is caching previous data, for some reason. Emptying monst.c completely makes no difference, but removing it makes the compiler complain about a missing file.

Here is the error in question:

C:\Nethack-src\nethack-3.4.3\src>mingw32-make -f makefile.gcc install
----
NOTE: This build will include tile support.
----
creating directory o
gcc -c -mms-bitfields -I../include -I../win/win32 -g -DTILES -DMSWIN_GRAPHICS -D
_WIN32_IE=0x0400 -oo/makedefs.o ../util/makedefs.c
gcc -c -mms-bitfields -I../include -I../win/win32 -g -DTILES -DMSWIN_GRAPHICS -D
_WIN32_IE=0x0400 -DDLB  -oo/monst.o /monst.c
/monst.c:1:9: error: expected declaration specifiers or '...' before string cons
tant
     MON("test lizard", S_LIZARD,
         ^
/monst.c:1:24: error: unknown type name 'S_LIZARD'
     MON("test lizard", S_LIZARD,
                        ^
/monst.c:2:2: error: unknown type name 'LVL'
  LVL(12, 16, 0, 50, 7), (G_GENO|1),
  ^
/monst.c:2:25: error: expected declaration specifiers or '...' before '(' token
  LVL(12, 16, 0, 50, 7), (G_GENO|1),
                         ^
/monst.c:3:2: error: unknown type name 'A'
  A(ATTK(AT_CLAW, AD_PHYS, 1, 10), NO_ATTK,
  ^
/monst.c:5:2: error: unknown type name 'SIZ'
  SIZ(2600, 400, 0, MS_MUMBLE, MZ_HUGE), MR_POISON, MR_POISON,
  ^
/monst.c:5:41: error: unknown type name 'MR_POISON'
  SIZ(2600, 400, 0, MS_MUMBLE, MZ_HUGE), MR_POISON, MR_POISON,
                                         ^
/monst.c:5:52: error: unknown type name 'MR_POISON'
  SIZ(2600, 400, 0, MS_MUMBLE, MZ_HUGE), MR_POISON, MR_POISON,
                                                    ^
/monst.c:6:2: error: unknown type name 'M1_NOLIMBS'
  M1_NOLIMBS|M1_SLITHY|M1_THICK_HIDE|M1_OVIPAROUS|M1_POIS|M1_NOTAKE|
  ^
/monst.c:8:2: error: unknown type name 'M2_STRONG'
  M2_STRONG, 0, CLR_GREEN),
  ^
/monst.c:8:13: error: expected declaration specifiers or '...' before numeric co
nstant
  M2_STRONG, 0, CLR_GREEN),
             ^
/monst.c:8:16: error: unknown type name 'CLR_GREEN'
  M2_STRONG, 0, CLR_GREEN),
                ^
makefile.gcc:252: recipe for target 'o/monst.o' failed
mingw32-make: *** [o/monst.o] Error 1

C:\Nethack-src\nethack-3.4.3\src>pause
Press any key to continue . . .

How do I solve this?

  • Don't post links to code or error or other crucial information, you don't know if or when that link will become stale or invalid. Always include crucial information *in the question*. – Some programmer dude Jan 18 '15 at 01:53
  • As for your errors, you haven't forgotten a comma, a closing parenthesis or something similar to that? Start with the first line showing an error, if it's really all okay, then go to the *previous* line and look at that, and so on. – Some programmer dude Jan 18 '15 at 01:54
  • @JoachimPileborg I really am sure that I have not made any mistake in my code, considering that these errors happen in code that is not my own, and used to work before. I have not modified it in any way. I have even redownloaded the source and tried to compile that, but I'm getting the same errors. Also, thanks for the tip about linking to errors, will fix ASAP. –  Jan 18 '15 at 01:57

1 Answers1

0

Take a look at the build command:

gcc -c -mms-bitfields -I../include -I../win/win32 -g
    -DTILES -DMSWIN_GRAPHICS -D _WIN32_IE=0x0400 -DDLB  -oo/monst.o /monst.c

It's looking at monst.c in a completely different directory, namely /

You probably introduced this error in the makefile after your original changes; that is the time when your code changes also stopped being effective.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • Thank you, that was the problem! Turns out I'm a bit messy when it comes to backups, I had actually backed up a small code snippet in the root of my C drive. When the build command was looking for monst.c, it found it in the root of my C drive, incomplete and all. I removed the file, and it now compiles successfully. Many thanks. –  Jan 18 '15 at 02:45