首页 > 解决方案 > 是否有解决此错误的方法:预期标识符或数字常量前的“(”?

问题描述

我从这里下载 zip 源代码:http: //gnuwin32.sourceforge.net/packages/zip.htm

我在 windows10 上用 Mingw-w64 编译它。

我使用以下命令编译此源:

# mingw32-make -f win32/makefile.gcc zip.exe
gcc -c   -O3 -Wall -mms-bitfields  -fno-exceptions -fomit-frame-pointer -DWIN32 -DZIP64_SUPPORT -DFORCE_WIN32_OVER_UNIX -DLARGE_FILE_SUPPORT -DUNICODE_SUPPORT -DUSE_EF_UT_TIME -DNTSD_EAS -DNO_STREAMING_STORE -ID:/Progra~1/GnuWin32/include -I. -ozip.o zip.c

我收到以下错误:

In file included from zip.c:16:
zip.h:265:16: error: expected identifier or '(' before numeric constant
 #define CR     13        /* '\r' on ASCII machines; must be 13 due to EBCDIC */
                ^~
mingw32-make: *** [win32/makefile.gcc:113: zip.o] Error 1

我尝试评论定义 CR 的这一行,它有效,但编译器给了我另一个关于 CR 未声明的错误。

zipup.c:1220:53: error: 'CR' undeclared (first use in this function)
             if ((*buf++ = *b++) == '\n') *(buf-1) = CR, *buf++ = LF, len++;

我尝试通过修改代码来修复它,但我不知道错误的原因。而且我不知道如何解决它。

我已经像这样替换了定义:#define CR 13

并将定义行移动到文件中的其他位置。

但是编译器也给了我同样的错误:(我将定义从第 265 行移到第 79 行)

In file included from zip.c:16:
zip.h:79:16: error: expected identifier or '(' before numeric constant
 #define CR     13
                ^~
mingw32-make: *** [win32/makefile.gcc:113: zip.o] Error 1

我认为定义的代码是正确的,但我不知道为什么会出现错误,以及如何修复它。

标签: c

解决方案


推荐阅读