gcc-3.4编译strace-4.6

gcc 3.4编译strace-4.6的话,会遇到这样的错误:

block.c: In function `block_ioctl':
block.c:271: error: `BLKTRACESTOP' undeclared (first use in this function)
block.c:271: error: (Each undeclared identifier is reported only once
block.c:271: error: for each function it appears in.)
make[2]: *** [block.o] Error 1
make[2]: Leaving directory `/home/liangry/download/strace-4.6'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/liangry/download/strace-4.6'
make: *** [all] Error 2

问题不在第271行,而在于block.c前面的宏定义:

#ifndef BLKTRACESTART #define BLKTRACESTART _IO(0x12,116) #endif #ifndef BLKTRACESTART #define BLKTRACESTOP _IO(0x12,117) #endif

本意是如果没有定义BLKTRACESTART的话,定义BLKTRACESTART和BLKTRACESTOP,这是能够被gcc 4识别的,却不能够被gcc 3.4识别,所以需打上补丁:

--- block.c 2011-01-17 07:07:51.000000000 +0800 +++ block.c 2011-04-27 14:11:32.000000000 +0800 @@ -53,6 +53,7 @@ #endif #ifndef BLKTRACESTART #define BLKTRACESTART _IO(0x12,116) +#define BLKTRACESTOP _IO(0x12,117) #endif #ifndef BLKTRACESTART #define BLKTRACESTOP _IO(0x12,117)

在strace-4.6编译目录下,把上述内容保存为strace-4.6_gcc-3.4.patch,然后执行:

$ patch -p0 < strace-4.6_gcc-3.4.patch
patching file block.c

你可能感兴趣的:(IO,function,File,gcc,each,patch)