Sign in to follow this  

'iSockaddrLength' has not been declared

This topic is 3121 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to learn how to make programs with Winsock, but I can't get it to compile. Here is the code to my program currently. I got it from an online tutorial, but I can't remember which one. Anyway, the files I am using are inaddr.h, Qos.h, winsock.dll, WinSock2.h, WS2_32.Lib, and ws2def.h Whenever I try to compile, I get the following errors. I can't figure out what the problem is. I assume the problem is not with the headers, but I'm not sure where the errors are coming from in that case. ..\..\..\MicrosoftSDK\ws2def.h|225|error: `iSockaddrLength' has not been declared| ..\..\..\MicrosoftSDK\ws2def.h|225|error: expected `;' before "LPSOCKADDR"| ..\..\..\MicrosoftSDK\ws2def.h|610|error: `len' is not a type| ..\..\..\MicrosoftSDK\ws2def.h|610|error: expected `;' before "CHAR"| ..\..\..\MicrosoftSDK\ws2def.h|618|error: `namelen' has not been declared| ..\..\..\MicrosoftSDK\ws2def.h|618|error: expected `;' before "LPSOCKADDR"| ..\..\..\MicrosoftSDK\winsock2.h|137|error: expected constructor, destructor, or type conversion before '(' token| ..\..\..\MicrosoftSDK\winsock2.h|1119|error: `cbSize' is not a type| ..\..\..\MicrosoftSDK\winsock2.h|1119|error: expected `;' before "BYTE"| ..\..\..\MicrosoftSDK\winsock2.h|1259|error: `dwNumberOfProtocols' is not a type| ..\..\..\MicrosoftSDK\winsock2.h|1259|error: expected `;' before "LPAFPROTOCOLS"| ..\..\..\MicrosoftSDK\winsock2.h|1262|error: `dwNumberOfCsAddrs' is not a type| ..\..\..\MicrosoftSDK\winsock2.h|1262|error: expected `;' before "LPCSADDR_INFO"| ..\..\..\MicrosoftSDK\winsock2.h|1266|error: typedef `__struct_bcount' is initialized (use __typeof__ instead)| ..\..\..\MicrosoftSDK\winsock2.h|1266|error: `dwSize' was not declared in this scope| ..\..\..\MicrosoftSDK\winsock2.h|1266|error: expected `,' or `;' before "struct"| ..\..\..\MicrosoftSDK\winsock2.h|1283|error: expected constructor, destructor, or type conversion before ',' token| ..\..\..\MicrosoftSDK\winsock2.h|1283|error: expected constructor, destructor, or type conversion before ',' token| ..\..\..\MicrosoftSDK\winsock2.h|1283|error: expected constructor, destructor, or type conversion before ';' token| ..\..\..\MicrosoftSDK\winsock2.h|1312|error: `dwNumberOfProtocols' is not a type| ..\..\..\MicrosoftSDK\winsock2.h|1312|error: expected `;' before "LPAFPROTOCOLS"| ..\..\..\MicrosoftSDK\winsock2.h|1315|error: `dwNumberOfCsAddrs' is not a type| ..\..\..\MicrosoftSDK\winsock2.h|1315|error: expected `;' before "LPCSADDR_INFO"| ..\..\..\MicrosoftSDK\winsock2.h|1525|error: `__out_bcount_opt' has not been declared| ..\..\..\MicrosoftSDK\winsock2.h|1525|error: expected `,' or `...' before "struct"| ..\..\..\MicrosoftSDK\winsock2.h|1546|error: `__in_bcount' has not been declared| ..\..\..\MicrosoftSDK\winsock2.h|1546|error: expected `,' or `...' before "const"| ..\..\..\MicrosoftSDK\winsock2.h|1584|error: `__in_bcount' has not been declared| ..\..\..\MicrosoftSDK\winsock2.h|1584|error: expected `,' or `...' before "const"| ..\..\..\MicrosoftSDK\winsock2.h|1606|error: `__inout' has not been declared| ..\..\..\MicrosoftSDK\winsock2.h|1606|error: expected `,' or `...' before '*' token| ..\..\..\MicrosoftSDK\winsock2.h|1626|error: `__out_bcount_part' has not been declared| ..\..\..\MicrosoftSDK\winsock2.h|1626|error: expected `)' before ',' token| ..\..\..\MicrosoftSDK\winsock2.h|1626|error: expected identifier before '*' token| ..\..\..\MicrosoftSDK\winsock2.h|1626|error: expected initializer before "struct"| ..\..\..\MicrosoftSDK\winsock2.h|1647|error: `__out_bcount_part' has not been declared| ..\..\..\MicrosoftSDK\winsock2.h|1647|error: expected `)' before ',' token| ..\..\..\MicrosoftSDK\winsock2.h|1647|error: expected identifier before '*' token| ..\..\..\MicrosoftSDK\winsock2.h|1647|error: expected initializer before "struct"| ..\..\..\MicrosoftSDK\winsock2.h|1670|error: `__out_bcount' has not been declared| ..\..\..\MicrosoftSDK\winsock2.h|1670|error: expected `,' or `...' before "char"| ..\..\..\MicrosoftSDK\winsock2.h|1722|error: expected constructor, destructor, or type conversion before '(' token| ..\..\..\MicrosoftSDK\winsock2.h|1815|error: `__out_bcount_part' has not been declared| ..\..\..\MicrosoftSDK\winsock2.h|1815|error: expected `)' before ',' token| ..\..\..\MicrosoftSDK\winsock2.h|1815|error: expected identifier before "return"| ..\..\..\MicrosoftSDK\winsock2.h|1815|error: expected `,' or `...' before "return"| ..\..\..\MicrosoftSDK\winsock2.h|1815|error: expected initializer before "__out_data_source"| ..\..\..\MicrosoftSDK\winsock2.h|1833|error: expected constructor, destructor, or type conversion before '(' token| ..\..\..\MicrosoftSDK\winsock2.h|1865|error: `__inout_opt' has not been declared| ..\..\..\MicrosoftSDK\winsock2.h|1865|error: expected `,' or `...' before '*' token| ||More errors follow but not being shown.| ||Edit the max errors limit in compiler options...| ||=== Build finished: 50 errors, 0 warnings ===| main.cpp
#include <winsock.h>
#include <iostream>

using namespace std;

int main()
{
    WSADATA wsaData;   // if this doesn't work
    //WSAData wsaData; // then try this instead

    // MAKEWORD(1,1) for Winsock 1.1, MAKEWORD(2,0) for Winsock 2.0:

    if (WSAStartup(MAKEWORD(1,1), &wsaData) != 0)
    {
        fprintf(stderr, "WSAStartup failed.\n");
        exit(1);
    }

    cout << "It worked. Yay!!!" << endl;

    WSACleanup();
    return 0;
}



Share this post


Link to post
Share on other sites
I discovered something even weirder. Simply moving it to any other drive will allow it to compile just fine, it just refuses to compile when it is on the K drive for some reason.

Any ideas what the heck could be causing this?

Share this post


Link to post
Share on other sites
Nope, it doesn't work anywhere on the K drive, including being put directly in 'K:\'

Likewise, it works anywhere on the C drive, even if it is stuck inside 10 levels of directories.

Share this post


Link to post
Share on other sites

This topic is 3121 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this