首先,“windows unistd.h”是指位于此处的示例:"is there a replacement for unistd.h for windows?
我正在尝试按摩 knetfile.c这样它就可以为windows64编译。我的第一步是删除 unistd.h 包含,因为它在 Windows 上不可用。
fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
所以,我想我会用上面链接的插入式替换来掷骰子。但是,这显然不起作用,因为我现在收到了一系列错误和警告:
knetfile.c(189): error C2036: 'void *' : unknown size knetfile.c(236): warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
knetfile.c(264): warning C4244: '=' : conversion from 'SOCKET' to 'int', possible loss of data
knetfile.c(271): warning C4244: '=' : conversion from 'SOCKET' to 'int', possible loss of data
knetfile.c(300): warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data
knetfile.c(335): error C2143: syntax error : missing ';' before 'const'
knetfile.c(336): error C2065: 'p' : undeclared identifier
knetfile.c(336): error C2100: illegal indirection
knetfile.c(336): error C2065: 'p' : undeclared identifier
knetfile.c(337): error C2065: 'p' : undeclared identifier
knetfile.c(337): error C2100: illegal indirection
knetfile.c(337): error C2065: 'p' : undeclared identifier
knetfile.c(337): error C2100: illegal indirection
knetfile.c(337): error C2065: 'p' : undeclared identifier
knetfile.c(338): error C2065: 'p' : undeclared identifier
knetfile.c(338): warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int'
knetfile.c(338): warning C4024: 'strtoint64' : different types for formal and actual parameter 1
knetfile.c(378): warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data
knetfile.c(410): warning C4244: '=' : conversion from 'SOCKET' to 'int', possible loss of data
knetfile.c(430): warning C4244: 'initializing' : conversion from 'int64_t' to 'off_t', possible loss of data
knetfile.c(520): error C2036: 'void *' : unknown size
knetfile.c(537): warning C4244: 'function' : conversion from 'int64_t' to 'long', possible loss of data
knetfile.c(544): warning C4244: 'return' : conversion from 'int64_t' to 'off_t', possible loss of data
knetfile.c(553): warning C4244: 'return' : conversion from 'int64_t' to 'off_t', possible loss of data
knetfile.c(565): warning C4244: 'return' : conversion from 'int64_t' to 'off_t', possible loss of data
我想有一小部分宏或 typedef 缺失可以解决这个问题。有什么建议吗?
最佳答案
第一个错误
knetfile.c(189): error C2036: 'void *' : unknown size
是正确的,代码是错误的。对头文件进行再多的修补也无法改变不能对 void 指针进行指针运算的事实。
第五个错误
knetfile.c(335):错误 C2143:语法错误:缺少“;”在“常量”之前
也是正确的。在 C 中,所有声明都必须位于任何语句之前的 block 的开头。可能随着 C99 发生了变化,但 Microsoft 编译器不支持 C99。
关于c++ - 将 klib 的 knetfile.c|h 移植到 Windows,当我在 "windows unistd.h"中子时,我得到错误 C2036 : 'void *' : unknown size,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13020818/