c++ - Amazon EC2 上的 socket.h 中的编译器错误

标签 c++ amazon-ec2 bitcoin

我正在尝试在我的 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 选项集进行编译,但没有任何区别。这是我唯一能想到的。

最佳答案

我敢打赌,您拥有的某个头文件是 #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 ,您可以查看它是否按预期进行编译。特别是,如果有一个宏将某些东西定义为意外的东西,您会在编译器指出的位置看到明显错误的代码。

关于c++ - Amazon EC2 上的 socket.h 中的编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15737437/

相关文章:

rpc - 比特币 RPC 获取钱包外地址余额

laravel - 在 laravel 5.5 中调用未定义的函数 App\Http\Controllers\bcmul()

c++ - Eigen::MatrixXd 到 flann::Matrix<double> 转换

java - Playframework 2 - 部署到 ec2

c++ - 仅对类 NOT STATIC 的每个对象调用方法一次

security - AWS VPC 中的 TCP 包伪造

ruby-on-rails - 在 Amazon AMI EC2 上设置 Rails

c++ - 在fedora 21上使用自编译的OpenSSL编译bitcoin

c++ - 毫米 :hh:mm time with c++

.net - 使用此库 shlwapi.dll 中的 StrCmpLogicalW 函数在 C++ 中自然排序