欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > linux >内容正文

linux

Linux交叉编译问题strace解决 signalfd.c:15: xlat/sfd_flags.h:17: error: size of array 'type name' is negative

发布时间:2025/4/5 linux 81 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Linux交叉编译问题strace解决 signalfd.c:15: xlat/sfd_flags.h:17: error: size of array 'type name' is negative 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

产品不是很稳定,执行shell容易出现段错误,为了定位打算移植strace到嵌入式板子上,环境是MIPS平台,从github上下载的strace源码,编译ARM平台通过( ubuntu 12.04 交叉编译 arm 平台的 strace),但是编译MIPS平台的时候报如下错误:

mips-linux-gcc-4.3.6 -std=gnu99 -DHAVE_CONFIG_H -I./linux/mips -I./linux/mips -I./linux -I./linux -I. -I. -Wall -Wempty-body -Wformat-security -Wignored-qualifiers -Winit-self -Wlogical-op -Wmissing-parameter-type -Wnested-externs -Wold-style-declaration -Wold-style-definition -Woverride-init -Wsign-compare -Wtype-limits -Wwrite-strings -g -O2 -MT strace-signalfd.o -MD -MP -MF .deps/strace-signalfd.Tpo -c -o strace-signalfd.o `test -f 'signalfd.c' || echo './'`signalfd.c In file included from signalfd.c:15: xlat/sfd_flags.h:17: error: size of array 'type name' is negative make[2]: *** [strace-signalfd.o] Error 1 make[2]: Leaving directory `/home/openwrt/project/tmp/strace/strace' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/openwrt/project/tmp/strace/strace' make: *** [all] Error 2

Google了半天也没看有好的解决办法,后来看到一个类似的问题,它的解决方法是将报错的地方给注释掉了;-),嘿,还别说,这招还真有效。编译果然通过了。

//定义一个空函数,不做检查 # define static_assert(expr, message) //extern int (*strace_static_assert(int))[sizeof(int[2 * !!(expr) - 1])]/* 注释掉报错代码 # define static_assert(expr, message) \extern int (*strace_static_assert(int))[sizeof(int[2 * !!(expr) - 1])]*/

实际测试不影响使用,灵活编译解决问题!

总结

以上是生活随笔为你收集整理的Linux交叉编译问题strace解决 signalfd.c:15: xlat/sfd_flags.h:17: error: size of array 'type name' is negative的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。