You cannot #include wabdefs.h with VC++ 2005

The following code will not compile :-

#include <windows.h>
#include <wabdefs.h>

int main()
{
    return 0;
}

You’ll get a compiler error (C2371) saying that you are redefining WCHAR. The problem is that wabdefs.h defines WCHAR as a typedef for WORD, while winnt.h defines WCHAR as a typedef for wchar_t. In VC++ 2005, /Zc:wchar_t is on by default, which means that wchar_t is a totally different type from unsigned short, as older compilers would expect it to be. This is a definition clash and the bug is in winnt.h, and it’s amazing that the PSDK team didn’t pick this one. If you are an app developer, you can modify your local copy of winnt.h, but if you are a developer who works on a source code library, you are going to have some angry clients when you tell them that they need to edit their winnt.h to get the library to compile. This bug is a total pain in the ass and until the PSDK team fixes winnt.h, there’s no real workaround :grrr:

3 thoughts on “You cannot #include wabdefs.h with VC++ 2005”

  1. I’d say wabdefs.h is the buggy header here. winnt.h is a core header file that you’re always going to include, so it should define base types like WCHAR, DWORD, etc. wabdefs.h – some random header that isn’t a core file – shouldn’t be redefining commonly-used types like that.

  2. As Mike already said, why would they define a base type like WCHAR in a WAB header and how could they have missed something so obvious because you can’t even compile using the default settings?

Leave a Reply