irrnetlite probs - winsock dosent like me

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ortsa
Posts: 11
Joined: Sun Jul 27, 2008 4:14 pm

irrnetlite probs - winsock dosent like me

Post by ortsa »

Elp, iv added irrnet and enet to my project and all is fine except for when i include irrnet.h or enet.h i get loads of errors from winsock, they are all similar heres a sample -

winsock2.h(212) : error C2011: 'hostent' : 'struct' type redefinition

There are ones about macro and function redefinition aswell.

How can i stop this from happening?

Im using visual studio 2005
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

I'm really not an expert (C++ and winsock), but this message seem to indicate that one of your include is redefining the same STRUCT structure block again. Check for a duplicate name somewhere in your code to see if that's true. (duplicate STRUCT block definition)

Perhaps you put the same include somewhere in your code...
ortsa
Posts: 11
Joined: Sun Jul 27, 2008 4:14 pm

Post by ortsa »

ok will do
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

maybe you don't use guard blocks in your header files ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
ortsa
Posts: 11
Joined: Sun Jul 27, 2008 4:14 pm

Post by ortsa »

well after some tweaking around the problem has just gone away and everythings working

Btw what do you mean by "guard blocks"

Weird
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

These things are called include guards.
ortsa
Posts: 11
Joined: Sun Jul 27, 2008 4:14 pm

Post by ortsa »

Oh right im just not familiar with that name i use pragma comment all the time
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

ortsa wrote:Oh right im just not familiar with that name i use pragma comment all the time
I meant Acki. ;)
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

randomMesh wrote:These things are called include guards.
Image
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

Write them an email and ask to correct this. Thought the C::B guys knew better.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: irrnetlite probs - winsock dosent like me

Post by rogerborg »

ortsa wrote:Elp, iv added irrnet and enet to my project and all is fine except for when i include irrnet.h or enet.h i get loads of errors from winsock, they are all similar heres a sample -

winsock2.h(212) : error C2011: 'hostent' : 'struct' type redefinition
This is actually a classic Microsoft snafu. If you compile windows.h - by which I mean include it directly or include anything that includes it - before winsock2.h, then it explodes spectacularly. You have to ensure that you include winsock2.h before anything that includes windows.h

Suck it and see.

Code: Select all

#include <windows.h>
#include <winsock2.h> // ASSPLOSION!

void main(void) { }

Code: Select all

#include <winsock2.h> // Works...
#include <windows.h> // ...fine

void main(void) { }
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: irrnetlite probs - winsock dosent like me

Post by randomMesh »

rogerborg wrote:

Code: Select all

void main(void) { }
OMG! main() returns an int.
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

Code: Select all

void main()
Is a perfectly valid definition of main. The majority of C/C++ compilers will accept it, making it a kind of de facto standard.

Code: Select all

 int|void main(int argc, char *argv[]) { } 
(or argv** if you really wanted to)
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

Dark_Kilauea wrote:

Code: Select all

void main()
Is a perfectly valid definition of main. The majority of C/C++ compilers will accept it, making it a kind of de facto standard.
No, no, no!. A C99 standard compliant compiler could show undefined behaviour. Never ever use void main()!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I think it's even for C98 C++, but it's also just for the exit value. If you ignore the exit value it won't do any harm (though it's ugly to still use void there :wink: )
Post Reply