socklen_t undeclared when compiling .c code

后端 未结 5 926
-上瘾入骨i
-上瘾入骨i 2020-12-29 07:43

I am trying to compile this .c code in windows using MinGW (gcc file.c -o compiled.exe):

/***************************************************/ 
/* AUTHOR             


        
5条回答
  •  情话喂你
    2020-12-29 07:49

    Figure out which .h file it is defined in, and include it. On a Unix/Linux box, I'd start with a find/grep in /usr/include

    $ find /usr/include -name \*.h -print0 |xargs -0 grep -w socklen_t
    ...
    /usr/include/unistd.h:typedef __socklen_t socklen_t;
    ...
    /usr/include/sys/socket.h:         socklen_t *__restrict __addr_len);
    

    Looks like it's defined in unistd.h - but you've already got that one included, so I guess you're covered on that side. I don't know how you'd find which file to include on the Windows side.

提交回复
热议问题