整个错误是:错误C2065:socklen_t的:未声明的标识符
Error 1 error C2065: 'socklen_t' : undeclared identifier c:\users\richard\documents\visual studio 2010\projects\server\server\server.cpp 41 1 Server
这是有问题的线路:
int iRcvdBytes=recvfrom(iSockFd, buff, 1024000, 0, (struct sockaddr*)&cliAddr, (socklen_t*)&cliAddrLen);
我有这些标头包括:
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
我还将WS2_32.lib添加到Visual Studio 2010中的链接程序中。
还有什么可能导致这个问题?我只是试图重写我的简单UDP程序在Windows下工作。
http://stackoverflow.com/questions/3531474/socklen-t-undeclared-when-compiling-c-code – 2010-12-15 19:35:42