【问题标题】:'__u32 __fswab32(__u32)' cannot appear in a constant-expression in netinet/tcp_md5.h'__u32 __fswab32(__u32)' 不能出现在 netinet/tcp_md5.h 的常量表达式中
【发布时间】:2020-06-05 05:13:07
【问题描述】:

在我的一个代码中,我遇到了以下错误,因为我使用的是

========== 错误========

/auto/andpkg/rep_cache//wr-x86-xeon/5.0/sysroot/intel_xeon_32_core-wrs-linux/usr/include/linux/tcp.h:72:17: error: '__u32 __fswab32(__u32)' cannot appear in a constant-expression

===========================

于是我改成了netinet/tcp.h,错误就解决了。但是下一个头文件是 netinet/tcp_md5.h,我发现 netinet/tcp_md5.h 又包含 。所以现在我得到了同样的编译错误和一些重新声明错误。

=========重新声明错误===============

在 ../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/ 中包含的文件中包括/pre-os/netinet/tcp_md5.h:59:0, 来自../../../../zeromq/conf.x86it/../zeromq-4.0.1/src/options.hpp:38, 来自 ../../../../zeromq/conf.x86it/../zeromq-4.0.1/src/ctx.cpp:30: ../../../../zeromq/ conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre-os/x86it/os/linux/tcp.h:91:0: 错误:“TCP_NODELAY”重新定义 [-Werror] ../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing- sw/include/pre-os/netinet/tcp.h:148:0: 注意:这是前面定义的位置../../../../zeromq/conf.x86it/../zeromq -4.0.1/../../../../routing-sw/include/pre-os/x86it/os/linux/tcp.h:92:0:错误:“TCP_MAXSEG”重新定义[-Werror ] ../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre-os/ netinet/tcp.h:149:0:注意:这是前面定义的位置../../../../zeromq/conf.x86it/../zeromq-4.0.1/../ ../../../routing-sw/include/pre-os/x86it/os/linux/tcp.h:94:0: error: "TCP_KEEPIDLE" redefined [-Werror] ../../. ./../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre-os/netinet/tcp.h:158: 0:注意:这是之前定义的位置../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre-os/x86it /os/linux/tcp.h:95:0: 错误:“TCP_KEEPINTVL”重新定义 [-Werror] ../../../../zeromq/conf.x86it/../zeromq-4.0.1/ ../../../../routing-sw/include/pre-os/netinet/tcp.h:159:0: 注意:这是前面定义的位置../../.. /../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre-os/x86it/os/linux/tcp.h :96:0: 错误:“TCP_KEEPCNT”重新定义 [-Werror] ../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../.. /../routing-sw/include/pre-os/netinet/tcp.h:157:0: 注意:这是之前定义的位置

../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre- os/x86it/os/linux/tcp.h:24:8: 错误: 'struct tcphdr' 的重新定义 ../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre-os/netinet /tcp.h:67:8: 错误:“struct tcphdr”的先前定义

==========================

========== 常量表达式又报错了==========

../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre- os/x86it/os/linux/tcp.h:72:17: 错误:'__u32 __fswab32(__u32)' 不能出现在常量表达式中 ../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre-os/x86it /os/linux/tcp.h:72:17: 错误:函数调用不能出现在常量表达式中 ../../../../zeromq/conf.x86it/../zeromq-4.0.1/../../../../routing-sw/include/pre-os/x86it /os/linux/tcp.h:73:17: 错误:'__u32 __fswab32(__u32)' 不能出现在常量表达式中

=============

看起来有交叉依赖。有人遇到过这个问题吗?有什么办法可以解决这个问题?

【问题讨论】:

  • 问:你想做什么?从源代码构建zeromq?如果是这样,您是否为与您的开发工作站不同的平台进行交叉编译?
  • @FoggyDay 是的,你是对的。我的工作站是 centos x86_64,我正在为 windriver linux 编译。工具链是/auto/andpkg/rep_cache//wr-x86-xeon/5.0/sysroot/intel_xeon_32_core-wrs-linux。
  • @FoggyDay 在 c++ 配置标志中添加 -std=c++0x 后,编译正常。
  • 美丽 - 感谢您的跟进。请“接受”你的回答——听起来它对其他人也有用:)

标签: linux cross-compiling zeromq


【解决方案1】:

CXXFLAGS中添加-std=c++0x后,编译顺利:

CXXFLAGS = -Wall           \
           -pipe            \
           -g                \
           -O2                \
           -fno-crossjumping   \
           -fno-strict-aliasing \
           -march=pentiumpro     \
           --sysroot=/auto/andpkg/rep_cache//wr-x86-xeon/5.0/sysroot/intel_xeon_32_core-wrs-linux \
           -m32                    \
           -Wno-variadic-macros     \
           -std=c++0x

【讨论】:

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