## Recommended Posts

when ever I compile and include "winsock2.h" I get classes and structs which are redefined, If I uninclude the winsock2.h file, the functions of that header are undefined. would I be correct in assuming there is another winsock2.h file, but with out any functions somewhere in my link path? Its frustrating, because I am not including that file twice, and to boot If I dont include the winsock2.h file, the classes and structs dont return any errors even though I can't "find the reference" for them, maybe my linker looks for functions before classes, but still. ugh.

##### Share on other sites
What IDE are you using?

If VC++7 or above, try enabling "ShowIncludes" in the Advanced section of the project properties. That will show you which files are being included... natch.

If not, try searching for "winsock2.h" and search "Entire Solution" and/or all the include directories in your path. Find all the files where it is included, and see if you include THOSE headers.

...

It could also be that you are linking more than one static library where the symbols have been defined, and you have a linker error.

HTH

##### Share on other sites
codewarrior 9.4 (updated)

I am thinking about going to VC++ 2005 EE :(

##### Share on other sites
as usual, show code [smile]

##### Share on other sites
yeah... to Alpha_ProgDes you listen :)

...and maybe do a clean build. It's possible some .obj (.o) and .lib (.a) files contain the same symbols.

##### Share on other sites
I have recompiled, rid my self of prior object code.

the code is quite simple, all I would have to do is

#include "winsock2.h"

~main~
{

anycall to a winsock function; /// errp function redefined.

}

error redefined - anycall

I have put this in an involved project, and a simple hello world program, same issues. Im quite put off with my linker right now.

Im almost certain its codewarrior specific. This is a conceptual problem, not a matter of syntax, and it has to do with my linker seeing double, where I have been only able to find one header file.

THIS IS A PROBLEM WITH SETTINGS AND LINKING ISSUES WITH CODEWARRIOR 9, not a code issue.

##### Share on other sites
Checking out these lines from winsock2.h...

#ifndef _WINSOCK2API_#define _WINSOCK2API_#define _WINSOCKAPI_   /* Prevent inclusion of winsock.h in windows.h */

...this suggests that maybe you're including <windows.h> before <winsock2.h>?

But I haven't looked through winsock2.h thoroughly... you may need <windows.h> first to define data types like DWORD and UINT.

[EDIT] woop ... look at this:

Lines 35-41:

/* * Pull in WINDOWS.H if necessary */#ifndef _INC_WINDOWS#include <windows.h>#endif /* _INC_WINDOWS */

Just do away with #include <windows.h>, if you have that in your header.

##### Share on other sites
ill give it a shot, thanks.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628306
• Total Posts
2981941

• 9
• 11
• 11
• 11
• 10