简体   繁体   English

将klib的knetfile.c | h移植到windows,当我在“windows unistd.h”中输入时,我收到错误C2036:'void *':未知大小

[英]Porting klib's knetfile.c|h to windows, when I sub in the “windows unistd.h”, I get error C2036: 'void *' : unknown size

First, by "windows unistd.h", I mean the example located here: "is there a replacement for unistd.h for windows? 首先,通过“windows unistd.h”,我的意思是这里的例子: “是否有替换unistd.h for windows?

I am attempting to massage knetfile.c so that it can be compiled for windows64. 我试图按摩knetfile.c,以便它可以编译为Windows64。 My first step was to remove the unistd.h include, because it is not available on windows. 我的第一步是删除unistd.h include,因为它在Windows上不可用。

fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory 致命错误C1083:无法打开包含文件:'unistd.h':没有这样的文件或目录

So, I figured I'd roll the dice with the drop-in replacement linked to above. 所以,我想我会用上面链接的替代品掷骰子。 However, this is clearly not working, as I now get a whole series of errors and warnings: 但是,这显然不起作用,因为我现在得到一系列错误和警告:

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(189):错误C2036:'void *':未知大小knetfile.c(236):警告C4267:'function':从'size_t'转换为'int',可能丢失数据

knetfile.c(264): warning C4244: '=' : conversion from 'SOCKET' to 'int', possible loss of data knetfile.c(264):警告C4244:'=':从'SOCKET'转换为'int',可能丢失数据

knetfile.c(271): warning C4244: '=' : conversion from 'SOCKET' to 'int', possible loss of data knetfile.c(271):警告C4244:'=':从'SOCKET'转换为'int',可能丢失数据

knetfile.c(300): warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data knetfile.c(300):警告C4244:'=':从'__int64'转换为'int',可能会丢失数据

knetfile.c(335): error C2143: syntax error : missing ';' knetfile.c(335):错误C2143:语法错误:缺少';' before 'const' 'const'之前

knetfile.c(336): error C2065: 'p' : undeclared identifier knetfile.c(336):错误C2065:'p':未声明的标识符

knetfile.c(336): error C2100: illegal indirection knetfile.c(336):错误C2100:非法间接

knetfile.c(336): error C2065: 'p' : undeclared identifier knetfile.c(336):错误C2065:'p':未声明的标识符

knetfile.c(337): error C2065: 'p' : undeclared identifier knetfile.c(337):错误C2065:'p':未声明的标识符

knetfile.c(337): error C2100: illegal indirection knetfile.c(337):错误C2100:非法间接

knetfile.c(337): error C2065: 'p' : undeclared identifier knetfile.c(337):错误C2065:'p':未声明的标识符

knetfile.c(337): error C2100: illegal indirection knetfile.c(337):错误C2100:非法间接

knetfile.c(337): error C2065: 'p' : undeclared identifier knetfile.c(337):错误C2065:'p':未声明的标识符

knetfile.c(338): error C2065: 'p' : undeclared identifier knetfile.c(338):错误C2065:'p':未声明的标识符

knetfile.c(338): warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int' knetfile.c(338):警告C4047:'function':'const char *'的间接级别与'int'不同

knetfile.c(338): warning C4024: 'strtoint64' : different types for formal and actual parameter 1 knetfile.c(338):警告C4024:'strtoint64':正式和实际参数1的不同类型

knetfile.c(378): warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data knetfile.c(378):警告C4244:'=':从'__int64'转换为'int',可能会丢失数据

knetfile.c(410): warning C4244: '=' : conversion from 'SOCKET' to 'int', possible loss of data knetfile.c(410):警告C4244:'=':从'SOCKET'转换为'int',可能丢失数据

knetfile.c(430): warning C4244: 'initializing' : conversion from 'int64_t' to 'off_t', possible loss of data knetfile.c(430):警告C4244:'初始化':从'int64_t'转换为'off_t',可能丢失数据

knetfile.c(520): error C2036: 'void *' : unknown size knetfile.c(520):错误C2036:'void *':未知大小

knetfile.c(537): warning C4244: 'function' : conversion from 'int64_t' to 'long', possible loss of data knetfile.c(537):警告C4244:'function':从'int64_t'转换为'long',可能丢失数据

knetfile.c(544): warning C4244: 'return' : conversion from 'int64_t' to 'off_t', possible loss of data knetfile.c(544):警告C4244:'return':从'int64_t'转换为'off_t',可能会丢失数据

knetfile.c(553): warning C4244: 'return' : conversion from 'int64_t' to 'off_t', possible loss of data knetfile.c(553):警告C4244:'return':从'int64_t'转换为'off_t',可能会丢失数据

knetfile.c(565): warning C4244: 'return' : conversion from 'int64_t' to 'off_t', possible loss of data knetfile.c(565):警告C4244:'return':从'int64_t'转换为'off_t',可能会丢失数据

I imagine there is a small group of macros or typedefs missing that would clear this up. 我想有一小组宏或类型的缺失可以解决这个问题。 Any suggestions? 有什么建议么?

The first error 第一个错误

knetfile.c(189): error C2036: 'void *' : unknown size knetfile.c(189):错误C2036:'void *':未知大小

is simply correct, and the code is wrong. 是完全正确的,代码是错误的。 No amount of tinkering with header files is going to change the fact that you cannot do pointer arithmetic on void pointers. 没有任何修改头文件会改变你无法对void指针进行指针运算的事实。

The fifth error 第五个错误

knetfile.c(335): error C2143: syntax error : missing ';' knetfile.c(335):错误C2143:语法错误:缺少';' before 'const' 'const'之前

is also correct. 也是对的。 In C all declarations must be at the beginning of a block before any statements. 在C中,所有声明必须在任何语句之前的块的开头。 Possibly that changed with C99, but Microsoft compilers don't support C99. 可能会因C99而改变,但Microsoft编译器不支持C99。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM