Including winsock2.h problem
-
Hi, I have a project I'm working on using GLUT, openGL and a few libraries. Now I'm trying to add sockets to it and whenever I include winsock2.h (haven't even written any relevant code) syntax error : ',' at some line which is meaningless appears. The code compiles and runs if I don't include winsock2.h I'm using VC++ 2005. I have ws2_32.lib set up to link. I'm not including windows.h, MFC support. I just can't figure out what's wrong. Example code for winsock compiles and works. As an aside can anyone point to a cross platform sockets library? I think GTK has one but it's way too big.
-
Hi, I have a project I'm working on using GLUT, openGL and a few libraries. Now I'm trying to add sockets to it and whenever I include winsock2.h (haven't even written any relevant code) syntax error : ',' at some line which is meaningless appears. The code compiles and runs if I don't include winsock2.h I'm using VC++ 2005. I have ws2_32.lib set up to link. I'm not including windows.h, MFC support. I just can't figure out what's wrong. Example code for winsock compiles and works. As an aside can anyone point to a cross platform sockets library? I think GTK has one but it's way too big.
-
Hi, I have a project I'm working on using GLUT, openGL and a few libraries. Now I'm trying to add sockets to it and whenever I include winsock2.h (haven't even written any relevant code) syntax error : ',' at some line which is meaningless appears. The code compiles and runs if I don't include winsock2.h I'm using VC++ 2005. I have ws2_32.lib set up to link. I'm not including windows.h, MFC support. I just can't figure out what's wrong. Example code for winsock compiles and works. As an aside can anyone point to a cross platform sockets library? I think GTK has one but it's way too big.
I expect you probably need to include windows.h before winsock2.h. If you're looking for a cross platform sockets library I'd start with BSD sockets, probably in netBSD these days. It's where Microsoft started when they needed to 'source' a socket implementation for Win95 or so the rumour goes. ;)
Nothing is exactly what it seems but everything with seems can be unpicked.
-
I expect you probably need to include windows.h before winsock2.h. If you're looking for a cross platform sockets library I'd start with BSD sockets, probably in netBSD these days. It's where Microsoft started when they needed to 'source' a socket implementation for Win95 or so the rumour goes. ;)
Nothing is exactly what it seems but everything with seems can be unpicked.
No, in fact you need to include winsock2.h before windows.h because windows.h includes old winsock.h which interferes with the new one. Also winsock2.h may include windows.h anyway on line: #ifndef _INC_WINDOWS #include #endif I will check out the BSD sockets thing...thanks.
-
No, in fact you need to include winsock2.h before windows.h because windows.h includes old winsock.h which interferes with the new one. Also winsock2.h may include windows.h anyway on line: #ifndef _INC_WINDOWS #include #endif I will check out the BSD sockets thing...thanks.
You're right, I'd forgotten about that particular peculiarity. One of my first tasks in paid software development was to change a project from winsock to winsock2. Amazing how quickly I forget things :laugh:
Nothing is exactly what it seems but everything with seems can be unpicked.
-
You're right, I'd forgotten about that particular peculiarity. One of my first tasks in paid software development was to change a project from winsock to winsock2. Amazing how quickly I forget things :laugh:
Nothing is exactly what it seems but everything with seems can be unpicked.