0

我正在尝试使用 gcc -g -Wall -Wextra -DNDEBUG -pedantic -ansi 标志编译代码并使用 libev 库。我在eclipse中收到以下错误:

Description Resource    Path    Location    Type
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’  Project     line 827, external location: /usr/include/ev.h  C/C++ Problem
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’  Project     line 820, external location: /usr/include/ev.h  C/C++ Problem
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’  Project     line 821, external location: /usr/include/ev.h  C/C++ Problem
make: *** [src/Object/MySockets/MySockets.o] Error 1    Project         C/C++ Problem
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’    Project     line 551, external location: /usr/include/ev.h  C/C++ Problem
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’   Project     line 559, external location: /usr/include/ev.h  C/C++ Problem
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘unsigned’  Project     line 825, external location: /usr/include/ev.h  C/C++ Problem
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘unsigned’  Project     line 826, external location: /usr/include/ev.h  C/C++ Problem
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’  Project     line 822, external location: /usr/include/ev.h  C/C++ Problem
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’  Project     line 823, external location: /usr/include/ev.h  C/C++ Problem

我已经在 ubuntu 中安装了 libev-dev 包。

4

1 回答 1

1

您的-ansi标志会导致编译器仅接受 C89 代码,并且只会在标准头文件(glibc/gcc)中启用 C89 功能。

libev 不是为由严格的 c89 编译器编译而设计的,它至少需要一个 posix(或者可能是 win32)系统——而且很可能它也使用了一些 c99 特性。

于 2012-11-15T08:16:45.660 回答