qemu 安装 recipe for target 'block/file-posix.o' failed error: missing binary operator before token "(

最近尝试了在 Ubuntu 18.04 上编译安装 qemu-4.2,qemu-5.0.0,发现编译遇到了问题。
问题如下:

/usr/include/linux/swab.h: In function ‘__swab’:
  CC      hw/char/digic-uart.o
  CC      hw/char/omap_uart.o
  CC      hw/char/exynos4210_uart.o
xxx/qemu-5.0.0/include/qemu/bitops.h:20:34: warning: "sizeof" is not defined, evaluates to 0 [-Wundef]
 #define BITS_PER_LONG           (sizeof (unsigned long) * BITS_PER_BYTE)
                                  ^
xxx/qemu-5.0.0/include/qemu/bitops.h:20:41: error: missing binary operator before token "("
 #define BITS_PER_LONG           (sizeof (unsigned long) * BITS_PER_BYTE)

...

xxx/qemu-5.0.0/rules.mak:69: recipe for target 'block/file-posix.o' failed
make: *** [block/file-posix.o] Error 1
make: *** Waiting for unfinished jobs....

经过分析是因为预编译器不认识 sizeof 运算符1

因此应当避免使用 sizeof。解决办法,修改 qemu-5.0.0/include/qemu/bitops.h

 #define BITS_PER_LONG           (sizeof (unsigned long) * BITS_PER_BYTE)
 改成
 #define BITS_PER_LONG           (__SIZEOF_LONG__ * BITS_PER_BYTE)

  1. https://stackoverflow.com/questions/21338385/what-does-the-compiler-error-missing-binary-operator-before-token-mean ↩︎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值