socklen_t undeclared when compiling .c code

后端 未结 5 939
-上瘾入骨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:53

    Check your socket.h - that's most likely where it's defined. Your code compiles fine with CygWin since the socket.h contains (by virtue of the fact it includes cygwin/socket.h):

    typedef int socklen_t;
    

    As a kludge, you could try adding that line to your own code. But you should still investigate why it's missing and maybe raise a bug report.

    There's a great many pages complaining that MinGW doesn't support socklen_t, for example here, here, here and here, the last of which states that it lives in ws2tcpip.h as I defined it in my kludge above.

提交回复
热议问题