无法使用 MinGW 编译之前修改的 Nethack - 缓存问题?

标签 c windows-8 compiler-errors mingw nethack

最近,我正在摆弄 Nethack 的源代码,这是一款相当老的游戏。我使用本指南来帮助我入门:Compiling - Wikihack .

为了测试,我首先编译了原始源代码。经过一些调整后,我能够毫无问题地运行它。接下来,我对源代码进行了一些编辑,并根据现有的怪物添加了两个示例怪物。游戏编译没有任何问题,并且我的测试怪物出现在游戏中。

之后,我尝试稍微调整一下怪物并重新编译。但由于某种原因,我的任何调整都没有出现。我决定删除所有内容并从头开始,再次重建原始源,尚未进行任何修改。现在突然间,我遇到了错误,引用了缺少的测试怪物。

这怎么可能?我仔细检查了一下,这个测试怪物不在源代码中(为什么应该是?它是原始源代码)。我唯一的解释是编译器出于某种原因正在缓存以前的数据。完全清空 monst.c 没有什么区别,但删除它会使编译器提示缺少文件。

这是有问题的错误:

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 . . .

如何解决这个问题?

最佳答案

看一下构建命令:

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,即 /

您可能在最初的更改后在 makefile 中引入了此错误;那时您的代码更改也不再有效。

关于无法使用 MinGW 编译之前修改的 Nethack - 缓存问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28006374/

相关文章:

c - Malloc 初始化空指针

c - 这两行有什么区别?

windows - 生成的 Windows 应用商店应用程序包名称看起来很奇怪

javascript - 扩展 WinJS Promise 对象

c++ - 错误 : expected unqualified-id before '<' token (Template compilation issue)

android - 类型参数 t 具有不兼容的上界 View 和 ListView

c - 使用 ""初始化字符串

计算并解析 html 文件中的所有 href 链接

opencv - windows 8和windows phone 8的opencv图像编辑库

swift - 内部/bin/cp 命令失败。 xCode 编译器错误