2012-10-29 50 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語義」來修復警告。