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])]
	*/

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

猜你喜欢

转载自blog.csdn.net/fuyuande/article/details/89314954