473,287 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Getting Winsock.h instead of Winsock2.h MSVC++ Problem # 2

I am posting two threads because I have two different problems, but both have the same background information.

Common Background Information:

I am trying to rebuild code for a working, commercially sold application with only partial build instructions. The previous maintainer of the code (a

mixture of C and C++) is no longer with the company, but when he built the code he used MSVC++, and though I am not certain of the version he was

using, I think it was either 4.0 or 6.0. I have only a little experience building with this environment (I am otherwise a seasoned developer) so I need

help getting past a couple of issues that I have encountered. Computers (and backups of those computers) previously used for running this build are

now completely unavailable.

I have set up the build on my system using MSVC++ 6.0. The source repository contained a workspace (.dsw) file that I am using for all of the projects. I

do not have specific instructions for this product on how to adjust the references to libraries, includes, etc. for a particular machine, but I am using

instructions for this from a similar (in terms of languages and tools used) product that was written around the same time. I have gotten 43 of 53 classes

(projects) to build, but am getting primarily two errors with the remaining 10 clases (projects).

Because I know this code base was building properly (for someone else who is no longer available on a machine that is no longer available), I would

strongly prefer adjustments to the build environment over code modification to get it to work, so please focus your assistance/suggestions in this area.

Thanks !

Problem #2: Getting Winsock.h instead of Winsock2.h

Here is part of the output I am receiving when I build:

Compiling...
srvsys.c
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(701) : error C2065: 'WSANETWORKEVENTS' : undeclared identifier
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(701) : error C2146: syntax error : missing ';' before identifier 'netevents'
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(701) : error C2065: 'netevents' : undeclared identifier
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(702) : error C2275: 'DWORD' : illegal use of this type as an expression
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\windef.h(141) : see declaration of 'DWORD'
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(702) : error C2146: syntax error : missing ';' before identifier 'wait_value'
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(702) : error C2065: 'wait_value' : undeclared identifier
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(702) : error C2065: 'wait_index' : undeclared identifier
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(703) : error C2275: 'HANDLE' : illegal use of this type as an expression
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\winnt.h(342) : see declaration of 'HANDLE'
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(703) : error C2146: syntax error : missing ';' before identifier 'hSocketEvent'
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(703) : error C2065: 'hSocketEvent' : undeclared identifier
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(704) : error C2275: 'SOCKET' : illegal use of this type as an expression
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\winsock.h(40) : see declaration of 'SOCKET'
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(704) : error C2146: syntax error : missing ';' before identifier 'hIpcSocket'
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(704) : error C2065: 'hIpcSocket' : undeclared identifier
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(705) : error C2143: syntax error : missing ';' before 'type'
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(716) : warning C4013: 'WSACreateEvent' undefined; assuming extern returning

int
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(716) : error C2065: 'WSA_INVALID_EVENT' : undeclared identifier
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(722) : warning C4013: 'WSAEventSelect' undefined; assuming extern returning

int
D:\DEVELOP\Source\FAXFX\FAXFX\CCODE\FXAPI\SRVAPI\s rvsys.c(730) : warning C4022: 'WaitForSingleObject' : pointer mismatch for actual parameter

1
Here are lines 701 through 730 of srvsys.c:

Expand|Select|Wrap|Line Numbers
  1.     WSANETWORKEVENTS netevents;
  2.     DWORD wait_value, wait_index;
  3.     HANDLE hSocketEvent;
  4.     SOCKET hIpcSocket;
  5.     struct FXDEV_DS_MSG msg;
  6.  
  7.     sprintf( tcaller, "fxcipc(%6d)", GetCurrentThreadId( ) );
  8.     trace_add_caller( 0, tcaller );
  9.  
  10.     trace( 7, "Start IPCThreadProc.\n");
  11.  
  12.     del_shut( );
  13.  
  14.     hIpcSocket = ( SOCKET ) SocketHandle;
  15.  
  16.     if ( ( hSocketEvent = WSACreateEvent( ) ) == WSA_INVALID_EVENT )
  17.     {
  18.         trace( 3, "Error: Unable to create monitor event [%d].\n", WSAGetLastError( ) );
  19.         ExitProcess( 0 );
  20.     }
  21.  
  22.     if ( WSAEventSelect( hIpcSocket, hSocketEvent, FD_READ | FD_CLOSE ) == SOCKET_ERROR )
  23.     {
  24.         trace( 3, "Error: Unable to set monitor event [%d].\n", WSAGetLastError( ) );
  25.         ExitProcess( 0 );
  26.     }
  27.  
  28.     while ( 1 )
  29.     {    trace( 7, "Run IPCThreadProc.\n");
  30.         wait_value = WaitForSingleObject( hSocketEvent, INFINITE );
The WSA stuff is only in Winsock2.h, but for some reason I am getting Winsock.h. I know this for two reasons: 1) the error messages (see above)

indicate it, and 2) when I right click on SOCKET (in line 704 or in line 714) and chose "Go to Definition of SOCKET" it takes me to Winsock.H (not

Winsock2.h).

So the question is, "How am I getting Winsock.h when I know the code is designed and was previously built using Winsock2.h?"

Any thoughts or suggestions from an experienced MSVC++ user would be greatly appreciated.
Jun 3 '09 #1
4 5653
You need to #define WIN32_LEAN_AND_MEAN before every #include <Windows.h>
Jun 3 '09 #2
donbock
2,426 Expert 2GB
@unauthorized
Or define it on the command line to avoid changing any source code.
Jun 4 '09 #3
I received some suggestions that WIN32_LEAN_AND_MEAN should probably be set so that windows.h doesn't include winsock.h. I gave it a try even though my instincts told me that this would not be the root problem, since the workspace contains preprocessor definitions on every project, so if this is required it would already be there. Adding WIN32_LEAN_AND_MEAN to the preprocessor definitions of a couple of project caused a whole bunch of new errors and did not get rid of the old ones.

In response to suggestions that I have received regarding changing the order of include and library directory searches... I have tried several different orders with no noticeable impact. The order I have right now is Microsoft SDK first, third party includes and libraries second, and VC98 includes and libraries last. This seems the safest, but again no order seems to work (trying every single permutation would take quite a while.)

Lastly, and most importantly, it has come to my attention that the product that I am building is sold only for Server 2000 and Server 2003 and that the previous building of this code base was running on a Server 2003 system. Since I have been trying my builds on an XP machine, I am leaning towards setting up a virtual machine running Server 2003 in which to compile to see if this helps. However, since that will take a while to set up, I was hoping someone out there might have thoughts about whether or not this is likely to help.
Jun 4 '09 #4
It doesn't matter what OS you use to build the executable(s) so long as you are running it in a compatible OS and have the required libraries installed. It's not uncommon to built binaries that cannot be run in the local OS and debug them using a VM or a remote debugger. In fact, I do it all the time, since I can't be bothered to migrate to a x64 OS.

WIN32_LEAN_AND_MEAN will remove a bunch of stuff which was moved away from windows.h. You can still include these headers one by one, but you would have to look up the undefined symbols in MSDN and possibly inspect windows.h. If you want to get rid of winsock.h, you have to #define it.

With that said, the simplest course of action to debug this particular problem would be to edit your winsock.h by putting an #error directive in it, and if necessary increase the verbosity level of your compiler. This will give you a pretty good idea where it's being included.
Jun 4 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: N.Naeem | last post by:
Hello all i need a solution to the following problem I have an application which listens to a port for incoming connections from a client via a Winsock. let's call this Winsock1 Upon a...
3
by: Bill | last post by:
When vb6 Winsock.RemoteHost is set to "127.0.0.1", c# socket listener cannot hear connect request (my old vb6 winsock listener could hear it...). Why doesn't this work, and is there a work...
0
by: Dark_AvEnGer | last post by:
hello all, i am in the middle of writting a messenger program which uses display pictures similer to those of MSN. At the momment the server open the requested file using Open filename as #1 for...
1
by: Dom | last post by:
I'm new to c++. Just started learning it 24 hours ago. Am running into a compile problem. Please, no one waste the effort telling me to google it. I've been researching it for quite a while with no...
10
by: Ka | last post by:
Hi, all I use Redhat8.0, and I complie a program with wine in this box, my wine version is wine-20020605-2 by Redhat. and after install wine, I just locate the library in /usr/lib/wine ...
3
by: matro | last post by:
hi there, I'm using RegEx object with the string "(\)" to get arguments from a line like this: This line has got argument and one. the issue is that I obtain a MathCollection with "" and...
2
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before...
1
by: Nicolas Ghesquiere | last post by:
Hello I have a problem with my current program. The meaning of the program is to allow users to login to a server to allow them to access the internet. My program communicates with a MS isa...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.