2012-10-29 48 views
1

我,包括我的foo.cstat.h如下在GCC:如何应对“警告:内联函数`* stat64`宣布,但从来没有定义”与gnu99支持

#include <sys/stat.h> 

当我编译这个如下:

gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1 -DUSE_ZLIB -DUSE_BZLIB -O0 -g -Wformat -Wall -Wswitch-enum -Wextra -std=gnu99 -DDEBUG=1 -c foo.c -o objects/foo.o -I... 
gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1 -DUSE_ZLIB -DUSE_BZLIB -O0 -g -Wformat -Wall -Wswitch-enum -Wextra -std=gnu99 -DDEBUG=1 objects/foo.o -o ../bin/debug.foo ../lib/libfoo.a ... -lbz2 -lz 

我得到以下警告,这是特定于<sys/stat.h>功能:

In file included from foo.c:15:0: 
/usr/local/gcc-4.7.2/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/include-fixed/sys/stat.h:317:16: warning: inline function `lstat64` declared but never defined [enabled by default] 
/usr/local/gcc-4.7.2/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/include-fixed/sys/stat.h:255:16: warning: inline function `fstat64` declared but never defined [enabled by default] 
... 

我该如何解决这些警告中引用的问题?这似乎没有成为一个问题,直到我迁移到C99支持与-std=gnu99,但我不知道为什么。感谢您的任何建议。

+0

问题中的代码确实使用'lstat()'? – alk

+0

它使用'stat()'。相关的代码行是'struct stat buf; int i = stat(fn,&buf);' –

回答

8

添加-fgnu89-inline标志通过在C99模式下启用“传统的内联函数的GNU语义”来修复警告。