Compiling an application using Microsoft Visual C++ 6.0 with the SocketTools Library Edition APIs can result in error C2501 "missing storage-class or type specifiers" during compilation. This error occurs because earlier versions of Visual C++ and the Windows SDK did not define the DWORD_PTR data type, which is used throughout the SocketTools header file. This error can also occur with other versions of Visual C++ if the application was originally written in Visual C++ 6.0 and the project was imported into a later version of the compiler.
SocketTools includes native 64-bit support for the Windows platform and uses the DWORD_PTR data type, primarily in conjunction with callback functions. This is a safe data type that is defined in the BaseTsd.h header file that is included as part of the standard Windows SDK. For 32-bit applications, the DWORD_PTR type is 32 bits wide and the same as a DWORD. However, for 64-bit applications, the DWORD_PTR type is 64 bits wide. This allows a DWORD_PTR value to safely store a memory address (pointer), based on which platform is being targeted.
Visual C++ 6.0 and earlier versions did not define the DWORD_PTR type, and when it encounters its use in the SocketTools header file, it considers it to be an undefined type and generates an error. This is not an issue with later versions of Visual C++, or with versions of Visual C++ that are using the current version of the Windows SDK.
To resolve this problem, there are several options available:
1. Upgrade your application to use a current version of the Visual C++ compiler and Windows SDK. Visual C++ 6.0 is no longer supported by Microsoft and is not compatible with the current version of the SDK. While using a supported compiler is preferable, there have been significant changes between the Visual C++ 6.0 release and the current version of Visual C++ which may require you to rewrite portions of your code.
2. Define the DWORD_PTR data type using a typedef inside your own code. This would typically be done inside one of your header files, and should be defined prior to including the SocketTools header file. For 32-bit applications, the DWORD_PTR type would be defined as:
typedef unsigned long DWORD_PTR, *PDWORD_PTR;
3. If the error is occurring with a Visual C++ 6.0 project that was imported into a later version of the compiler, remove references to the older header files. When Visual C++ upgrades a project, it typically retains the original include paths for the header files used by the previous version. Make sure that your project is using the include files and libraries from the current version of Visual C++ that you are using.
The Visual C++ 6.0 IDE will not work correctly on Windows 11 using the workaround solutions that were available for Windows 10. In most cases the IDE will immediately crash, even when started with elevated privileges in compatibility mode. We do not recommend the installation of Visual C++ 6.0 or the Platform 2003 SDK on a Windows 11 system.