By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,369 Members | 1,692 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,369 IT Pros & Developers. It's quick & easy.

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

P: n/a
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'
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mark Fancy wrote:
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!

--
Brandon Bray http://blogs.gotdotnet.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.