【问题标题】:Compiler error in socket.h on Amazon EC2Amazon EC2 上的 socket.h 中的编译器错误
【发布时间】:2013-03-22 04:08:57
【问题描述】:

我正在尝试在我的 EC2 实例上编译比特币,但遇到了一个我无法弄清楚的问题。构建脚本在以下命令上停止

g++ -c -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g   -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE -DUSE_UPNP=1 -DUSE_IPV6=1 -I/home/ec2-user/bitcoin/src/leveldb/include -I/home/ec2-user/bitcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -I"/home/ec2-user/bitcoin/src" -I"/home/ec2-user/bitcoin/src/obj" -I"/usr/local/include" -I"/usr/include/openssl" -MMD -MF obj/alert.d -o obj/alert.o alert.cpp

通过返回以下错误

In file included from /usr/include/sys/socket.h:40:0,
                 from compat.h:19,
                 from netbase.h:11,
                 from util.h:27,
                 from alert.h:13,
                 from alert.cpp:11:
/usr/include/bits/socket.h:231:5: error: expected identifier before numeric constant
/usr/include/bits/socket.h:231:5: error: expected ‘}’ before numeric constant
/usr/include/bits/socket.h:231:5: error: expected unqualified-id before numeric constant
In file included from compat.h:19:0,
                 from netbase.h:11,
                 from util.h:27,
                 from alert.h:13,
                 from alert.cpp:11:
/usr/include/sys/socket.h:254:1: error: expected declaration before ‘}’ token

我尝试使用 -std=c++0x 选项集进行编译,但没有任何区别。这是我唯一能想到的。

【问题讨论】:

    标签: c++ amazon-ec2 bitcoin


    【解决方案1】:

    我敢打赌,您拥有的某些头文件是 #define 一个会干扰 socket.h 的宏。你能编译一个只包含<sys/socket.h>而没有其他包含的程序吗?

    接下来要检查的是查看/usr/include/bits/socket.h 并查看第 231 行(第一个错误发生的位置)上的内容。如果代码看起来没问题,那么下一步就是看看预处理后的源代码是什么样子的。要获取预处理输出,请将命令行中的-c 选项替换为-E,并将-o obj/alert.o 选项更改为-o alert.ii 以将预处理器输出放入文件alert.ii。

    如果您比较alert.ii 和/usr/include/bits/socket.h 的内容,您可以查看它是否按预期编译。特别是,如果有一个宏将某些东西定义为意想不到的东西,您会在编译器指出的位置看到明显错误的代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-24
      • 1970-01-01
      相关资源
      最近更新 更多