Can't compile simple WSAEnumProtocols()

This is a discussion on Can't compile simple WSAEnumProtocols() within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I cannot get a simple WSAEnumProtocols to compile. What's wrong? Thank you. The program e1.c: Code: //gcc e1.c -lws2_32 ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    57

    Can't compile simple WSAEnumProtocols()

    Hello,
    I cannot get a simple WSAEnumProtocols to compile.
    What's wrong?
    Thank you.

    The program e1.c:
    Code:
    //gcc e1.c -lws2_32 -o e1.exe
    #include <windows.h>
    #include <stdio.h>
    #include <winsock2.h>
    
    
    int main(VOID) {
      WSADATA Data;
      int status;
      WSAPROTOCOL_INFO wpi[10];
      ILPDWORD iii;
    
      /* initialize the Windows Socket DLL */
      status=WSAStartup(MAKEWORD(1, 1), &Data);
      if (status != 0) {
         printf("WSAStartup unsuccessful");
         return(1);
      }
      
      iii = sizeof(WSAPROTOCOL_INFO)*10;
      status = WSAEnumProtocols(NULL, wpi, &iii );
    
      printf("status: %d\n",status);
      printf("iii: %d\n",iii);
    
    }
    The compile error message:
    Code:
    C:\gcc\Progs\examples>gcc e1.c -lws2_32 -o e1.exe
    e1.c: In function `main':
    e1.c:11: error: `ILPDWORD' undeclared (first use in this function)
    e1.c:11: error: (Each undeclared identifier is reported only once
    e1.c:11: error: for each function it appears in.)
    e1.c:11: error: parse error before "iii"
    e1.c:20: error: `iii' undeclared (first use in this function)
    
    C:\gcc\Progs\examples>
    Also, I can't find the definition for "ILPDWORD".

    Thanks for any help.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    change ILPDWORD to LPDWORD

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    http://msdn.microsoft.com/library/de...rotocols_2.asp

    'Tis an LPDWORD, meaning, a pointer to a DWORD. You would probably declare 'iii' as a DWORD and then pass the address-of 'iii' to the API.

  4. #4

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    57
    Thanks for the help.

    I changed ILPDWORD to LPDWORD and still got an error.

    Code:
    C:\gcc\Progs\examples>gcc e1.c -lws2_32 -o e1.exe
    e1.c: In function `main':
    e1.c:20: warning: assignment makes pointer from integer without a cast
    e1.c:21: warning: passing arg 3 of `WSAEnumProtocolsA' from incompatible pointer type
    Can someone please just post a corrected example that works.

    Thanks.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Code:
    int main(VOID) {
      WSADATA Data;
      int status;
      WSAPROTOCOL_INFO wpi[10];
      DWORD iii;
    
      /* initialize the Windows Socket DLL */
      status=WSAStartup(MAKEWORD(1, 1), &Data);
      if (status != 0) {
         printf("WSAStartup unsuccessful");
         return(1);
      }
      
      iii = sizeof(WSAPROTOCOL_INFO)*10;
      status = WSAEnumProtocols(NULL, wpi, &iii );
    
      printf("status: %d\n",status);
      printf("iii: %d\n",iii);
    
    }

  7. #7
    Registered User
    Join Date
    Sep 2004
    Posts
    57
    Thanks bithub.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple program with svgalib = no compile?
    By IM back! in forum C++ Programming
    Replies: 1
    Last Post: 05-29-2008, 03:10 PM
  2. auto_ptr assignment compile error
    By George2 in forum C++ Programming
    Replies: 7
    Last Post: 04-01-2008, 02:44 AM
  3. Have no idea how to compile c++, please help (newbie qn)
    By rholloway in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2008, 07:31 AM
  4. Why wont this simple class compile?
    By deadpoet in forum C++ Programming
    Replies: 2
    Last Post: 01-08-2004, 11:16 AM
  5. what SHOULD be a painfully simple API call...
    By Citizen Bleys in forum Windows Programming
    Replies: 3
    Last Post: 09-17-2003, 03:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21