2011-12-09 32 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