/Tc:wchar_t cause C2371 in MAPIDefS.h & WinNT.h

M

Mark Fancy

I have a project that I'm trying to get to compile. I
need to have the /Tc:wchar_t compile switch in order to
use some libraries. I have included the following header
files:
#include <mapix.h>
#include <mapiutil.h>
#include <imessage.h>
#include <mapitags.h>

When I try to compile my project I get the following error:

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7
\PlatformSDK\Include\MAPIDefS.h(76) : error
C2371: 'WCHAR' : redefinition; different basic types
c:\Program Files\Microsoft Visual Studio .NET 2003
\Vc7\PlatformSDK\Include\WinNT.h(267) : see declaration
of 'WCHAR'
 
B

Brandon Bray [MSFT]

Mark said:
I have a project that I'm trying to get to compile. I
need to have the /Tc:wchar_t compile switch in order to
use some libraries. I have included the following header
files:
[SNIP]

Yep, this is a problem with the PSDK headers. winnt.h has the following
line:

typedef wchar_t WCHAR; // wc, 16-bit UNICODE character

Without /Zc:wchar_t, the compiler treats wchar_t as a typedef for unsigned
short. With Zc:wchar_t, the compiler treats wchar_t as a completely
different type.

mapidefs.h has the following line:

typedef WORD WCHAR;

And WORD is defined as follows in windef.h:

typedef unsigned short WORD;

Without /Zc:wchar_t, WCHAR has the same meaning with each of its
redeclarations. With /Zc:wchar_t, WCHAR means something different and hence
the compiler error. This is a bug that the Platform team needs to fix, and
I'll notify them of this. In the meantime, you can change your own copy of
these files. Probably the easiest fix will be to change winnt.h to use
"unsigned short" instead of WCHAR. If you do change your own copy, make sure
you look at differences when you update your copy of the PSDK.

Cheerio!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top