2011-12-09 35 views
0

這個問題有點特別,但是在這裏:我想在SDL中使用ZZipLib。 (http://zziplib.sourceforge.net/)ZZipLib附帶一個名爲SDL_rwops_zzip.c的文件,專門用於簡化插入SDL文件調用的過程。事實上,我在Mac上完成了這個任務,沒有任何問題。在SDL中使用ZZipLib? (編譯SDL_rwops_zzip.c)

問題是在Windows上它不會編譯。有問題的代碼是從SDL_rwops_zzip.c:

#define SDL_RWOPS_ZZIP_DATA(_context) \ 
     ((_context)->hidden.unknown.data1) 
#define SDL_RWOPS_ZZIP_FILE(_context) (ZZIP_FILE*) \ 
     ((_context)->hidden.unknown.data1) 

static int _zzip_seek(SDL_RWops *context, int offset, int whence) // line 30 
{ 
    return zzip_seek(SDL_RWOPS_ZZIP_FILE(context), offset, whence); 
} 

的錯誤,我得到的是:

SDL_rwops_zzip.c(31):警告C4028:正式參數1不同於聲明 SDL_rwops_zzip.c(31) :警告C4028:形式參數3不同於聲明 SDL_rwops_zzip.c(31):警告C4029:聲明的形式參數列表與定義不同 SDL_rwops_zzip.c(31):錯誤C2491:'_read':不允許定義dllimport函數

此堆棧溢出pos t給出了一些有關該錯誤的信息: definition of dllimport function not allowed

但我真的不明白在這種特殊情況下如何解決這個錯誤。

回答

1

我解決了這個問題,通過使用從頭開始構建的Visual Studio 10項目(升級後的Visual Studio 7項目沒有生成工作庫或.dll)重新編譯zziplib,然後在conf中註釋掉這些行。 H:

# if !__STDC__ 
# ifndef _zzip_lseek 
# define _zzip_lseek _lseek 
# endif 
# ifndef _zzip_read 
# define _zzip_read _read 
# endif 
# ifndef _zzip_write 
# define _zzip_write _write 
# endif 
#  if 0 
# ifndef _zzip_stat 
# define _zzip_stat _stat 
# endif 
#  endif 
# endif // !__STDC__ 
#endif 

這:

# ifndef _zzip_lseek 
# define _zzip_lseek lseek 
# endif 

# ifndef _zzip_read 
# define _zzip_read read 
# endif 

# ifndef _zzip_write 
# define _zzip_write write 
# endif