problem with winsock2.h

Started by zzen, November 10, 2008, 10:40:23 PM

Previous topic - Next topic

zzen

 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



Pelle

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

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

Quote from: zzen 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.

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


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

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

#6


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

zzen

Moving the windows.h header was the fix!

Thanks for all the help