0

First, by "windows unistd.h", I mean the example located here: "is there a replacement for unistd.h for windows?

I am attempting to massage knetfile.c so that it can be compiled for windows64. My first step was to remove the unistd.h include, because it is not available on windows.

fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory

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(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

I imagine there is a small group of macros or typedefs missing that would clear this up. Any suggestions?

0

1 Answer 1

2

The first error

knetfile.c(189): error C2036: 'void *' : unknown size

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.

The fifth error

knetfile.c(335): error C2143: syntax error : missing ';' before 'const'

is also correct. In C all declarations must be at the beginning of a block before any statements. Possibly that changed with C99, but Microsoft compilers don't support C99.

3
  • It could be that the unistd.h he was getting from somewhere typedef'd it wrong.
    – quantum
    Oct 22, 2012 at 22:35
  • 2
    No the code says void* buf and then buf + 1. That's just wrong.
    – john
    Oct 22, 2012 at 22:36
  • This was the answer. The author allocated these pointers as char *, then for an unknown reason, passed them around as void *. Thanks!
    – rlong
    Oct 23, 2012 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.