2012-11-27 113 views
0

我試圖編譯包含liboss文件的程序,但是當我編譯時出現以下錯誤。'ioctl'的liboss靜態聲明遵循非靜態聲明

In file included from test.c:1: 
/opt/local/include/liboss/soundcard.h:342: error: static declaration of ‘ioctl’ follows non-static declaration 
/usr/include/sys/ioctl.h:97: error: previous declaration of ‘ioctl’ was here 
/opt/local/include/liboss/soundcard.h:353: error: static declaration of ‘open’ follows non-static declaration 
/usr/include/sys/fcntl.h:464: error: previous declaration of ‘open’ was here 
/opt/local/include/liboss/soundcard.h:363: error: static declaration of ‘close’ follows non-static declaration 
/usr/include/unistd.h:476: error: previous declaration of ‘close’ was here 
/opt/local/include/liboss/soundcard.h:366: error: conflicting types for ‘write’ 
/usr/include/unistd.h:535: error: previous declaration of ‘write’ was here 

其中發生的第一錯誤的線是這個。

@ soundcard.h

static inline int LIBOSS_IOCTL (int x, unsigned long y,...) 
{ 
    int result; 

    va_list l; 
    va_start(l,y); 
    result = liboss_ioctl(x,y,l); 
    va_end (l); 
    return result; 
} 

@ ioctl.h

__BEGIN_DECLS 
int ioctl(int, unsigned long, ...); 
__END_DECLS 

有沒有什麼辦法。我在猴子補丁soundcard.h所以,這不會是一個問題?

Thnx! A.

規格:Mac OSX版10.7.4,GCC的i686-蘋果darwin11-LLVM-GCC-4.2(GCC)4.2.1

回答

0

這聽起來像liboss正試圖提供一個開放源碼軟件兼容聲卡接口在非本地系統上,通過重新定義ioctl函數來提供OSS ioctl操作,而內核不支持它們。如果是這種情況,您需要確保sys/ioctl.h(或任何可能包含它的頭文件)不會包含在使用soundcard.h的相同源文件中。

+0

嘗試了它,現在它只跳到以下錯誤(請參閱問題)。 soundcard.h中有一個#undef指令。難道這不會訣竅嗎?爲什麼它不工作? – misterte

0

只需將static添加到/usr/include/sys/ioctl.h:97,/usr/include/sys/fcntl.h:464,/usr/include/unistd.h:476/usr/include/unistd.h:535(並在編譯後再次撤銷這些更改)。

/opt/local/include/liboss/soundcard.h:366取代int通過ssize_t

# add static 
sudo nano +97 /usr/include/sys/ioctl.h 
- int ioctl(int, unsigned long, ...); 
+ static int ioctl(int, unsigned long, ...); 

# replace int by ssize_t 
sudo nano +366 /opt/local/include/liboss/soundcard.h 
- static inline int LIBOSS_WRITE (int x, const void *y, size_t l) 
+ static inline ssize_t LIBOSS_WRITE (int x, const void *y, size_t l)