NO

Author Topic: problem with winsock2.h  (Read 5128 times)

zzen

  • Guest
problem with winsock2.h
« on: November 10, 2008, 10:40:23 PM »
 I have some code that compiled find with version 4.5. I just downloaded 5.01 and am getting many redefinition errors like:
C:\PellesC\Include\Win\ws2def.h(39): error #1050: Macro redefinition of 'AF_IPX'.
C:\PellesC\Include\Win\ws2def.h(63): error #1050: Macro redefinition of 'AF_MAX'.
C:\PellesC\Include\Win\ws2def.h(94): error #1050: Macro redefinition of 'SO_DONTLINGER'.
C:\PellesC\Include\Win\ws2def.h(341): error #1050: Macro redefinition of 'IN_CLASSA'.

Am I missing something or is this a problem with  winsock2.h?

Attached is error winsock2.txt with all the errors listed



Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: problem with winsock2.h
« Reply #1 on: November 11, 2008, 06:22:39 PM »
winsock2.h has always been tricky in the world of Microsoft, but if you include it *before* windows.h (or even skip windows.h) it usually works...

#include <winsock2.h>
#include <windows.h>
/Pelle

zzen

  • Guest
Re: problem with winsock2.h
« Reply #2 on: November 13, 2008, 01:46:35 AM »
I removed windows.h but now I am getting many errors with commctrl.h
Moving commctrl.h before or after other header files does not solve anything.
Basically you can not use standard windows header files in version 5.

JohnF

  • Guest
Re: problem with winsock2.h
« Reply #3 on: November 13, 2008, 11:07:08 AM »
I removed windows.h but now I am getting many errors with commctrl.h
Moving commctrl.h before or after other header files does not solve anything.
Basically you can not use standard windows header files in version 5.

Pelle said

============
winsock2.h has always been tricky in the world of Microsoft, but if you include it *before* windows.h
============

Try again.

John

zzen

  • Guest
Re: problem with winsock2.h
« Reply #4 on: November 13, 2008, 01:54:30 PM »

As stated before, lots of errors. Attached is the errors received. 
list of header files:

#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <winsock2.h>
#include <commctrl.h>
#include <windows.h>
#include <stdlib.h>
//#include <malloc.h>
#include <time.h>
#include <direct.h>
#include <math.h>
#include <process.h>
#include "getdata.h"
#include "getdataf.h"
#include "scaldate.h"
#include "fileini.h"
#include "getdatares.h"

zzen

  • Guest
Re: problem with winsock2.h
« Reply #5 on: November 13, 2008, 02:08:14 PM »
Correction I hit "rebuild all" the errors are created from the first souce file.The new errors have nothing to do with winsock2.h.  error list is attached.
Header list:

#include <commctrl.h>
#include <windows.h>
#include <shellapi.h>
#include <string.h>
#include <stdio.h>
#include <sys/stat.h>
#include <io.h>
#include <process.h>
#include <math.h>
#include "fileini.h"
#include "getdata.h"
#include "getdataf.h"
#include "scaldate.h"
 

JohnF

  • Guest
Re: problem with winsock2.h
« Reply #6 on: November 13, 2008, 03:39:03 PM »


windows.h must come before most other windows headers, except winsock2.h of course, because including windows.h first, defines many of the things that other windows headers need.

#include <windows.h>
#include <commctrl.h>

John
« Last Edit: November 13, 2008, 03:46:02 PM by JohnF »

zzen

  • Guest
Re: problem with winsock2.h
« Reply #7 on: November 14, 2008, 01:47:07 AM »
Moving the windows.h header was the fix!

Thanks for all the help