D:\Download\UDP_CarSim>gcc tcp_test.c
cc1: error: no include path in which to search for stdc-predef.h
tcp_test.c:4:21: error: no include path in which to search for process.h
#include <process.h>
? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:5:19: error: no include path in which to search for stdio.h
#include <stdio.h>
? ? ? ? ? ? ? ? ? ^
tcp_test.c:6:22: error: no include path in which to search for winsock2.h
#include <winsock2.h>
? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:7:20: error: no include path in which to search for stdlib.h
#include <stdlib.h>
? ? ? ? ? ? ? ? ? ? ^
tcp_test.c: In function 'main':
tcp_test.c:14:5: error: unknown type name 'WORD'
? ? WORD sockVersion = MAKEWORD(2,2);
? ? ^
tcp_test.c:15:5: error: unknown type name 'WSADATA'
? ? WSADATA wsaData;
? ? ^
tcp_test.c:22:5: error: unknown type name 'SOCKET'
? ? SOCKET slisten = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
? ? ^
tcp_test.c:22:29: error: 'AF_INET' undeclared (first use in this function)
? ? SOCKET slisten = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:22:29: note: each undeclared identifier is reported only once for each function it appears in
tcp_test.c:22:38: error: 'SOCK_STREAM' undeclared (first use in this function)
? ? SOCKET slisten = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:22:51: error: 'IPPROTO_TCP' undeclared (first use in this function)
? ? SOCKET slisten = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:23:19: error: 'INVALID_SOCKET' undeclared (first use in this function)
? ? if(slisten == INVALID_SOCKET)
? ? ? ? ? ? ? ? ? ^
tcp_test.c:25:9: warning: incompatible implicit declaration of built-in function 'printf'
? ? ? ? printf("socket error !");
? ? ? ? ^
tcp_test.c:31:5: error: unknown type name 'SOCKADDR_IN'
? ? SOCKADDR_IN sin;
? ? ^
tcp_test.c:32:8: error: request for member 'sin_family' in something not a structure or union
? ? sin.sin_family = AF_INET;
? ? ? ? ^
tcp_test.c:33:8: error: request for member 'sin_port' in something not a structure or union
? ? sin.sin_port = htons(8888);
? ? ? ? ^
tcp_test.c:34:8: error: request for member 'sin_addr' in something not a structure or union
? ? sin.sin_addr.S_un.S_addr = INADDR_ANY;
? ? ? ? ^
tcp_test.c:34:32: error: 'INADDR_ANY' undeclared (first use in this function)
? ? sin.sin_addr.S_un.S_addr = INADDR_ANY;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:35:23: error: 'LPSOCKADDR' undeclared (first use in this function)
? ? if(bind(slisten, (LPSOCKADDR)&sin, sizeof(sin)) == SOCKET_ERROR)
? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:35:56: error: 'SOCKET_ERROR' undeclared (first use in this function)
? ? if(bind(slisten, (LPSOCKADDR)&sin, sizeof(sin)) == SOCKET_ERROR)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:37:9: warning: incompatible implicit declaration of built-in function 'printf'
? ? ? ? printf("bind error !");
? ? ? ? ^
tcp_test.c:43:9: warning: incompatible implicit declaration of built-in function 'printf'
? ? ? ? printf("listen error !");
? ? ? ? ^
tcp_test.c:48:5: error: unknown type name 'SOCKET'
? ? SOCKET sClient;
? ? ^
tcp_test.c:49:5: error: unknown type name 'SOCKADDR_IN'
? ? SOCKADDR_IN remoteAddr;
? ? ^
tcp_test.c:52:12: error: 'TRUE' undeclared (first use in this function)
? ? while (TRUE)
? ? ? ? ? ? ^
tcp_test.c:54:9: warning: incompatible implicit declaration of built-in function 'printf'
? ? ? ? printf("wait for connecting...\n");
? ? ? ? ^
tcp_test.c:55:36: error: 'SOCKADDR' undeclared (first use in this function)
? ? ? ? sClient = accept(slisten, (SOCKADDR *)&remoteAddr, &nAddrlen);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:55:46: error: expected expression before ')' token
? ? ? ? sClient = accept(slisten, (SOCKADDR *)&remoteAddr, &nAddrlen);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:61:68: error: request for member 'sin_addr' in something not a structure or union
? ? ? ? printf("accepted a connect锛?s \r\n", inet_ntoa(remoteAddr.sin_addr));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^
tcp_test.c:73:33: warning: incompatible implicit declaration of built-in function 'strlen'
? ? ? ? send(sClient, sendData, strlen(sendData), 0);
Path新增:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
include:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt;C:\build\17.0\x64\sysroots\core2-64-nilrt-linux\usr\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\src\atl\atls;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared;
LIB:?C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\onecore\x64;