1
votes

I am getting C++ Compiler error C2371 when I include a header file that itself includes odbcss.h. My project is set to MBCS.

C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\odbcss.h(430) : error C2371: 'WCHAR' : redefinition; different basic types 1>
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winnt.h(289) : see declaration of 'WCHAR'

I don't see any defines in odbcss.h that I could set to avoid this. Has anyone else seen this?

4

4 Answers

2
votes

This is a known bug - see the Microsoft Connect website:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98699

The error doesn't occur if you compile your app as Unicode instead of MBCS.

1
votes

There are a half-dozen posts on various forums around the web about this - it seems to potentially be an issue when odbcss.h is used in the presence of MFC. Most of the answers involve changing the order of included headers (voodoo debugging). The header that includes odbcss.h compiles fine in it's native project, but when it is included in a different project, it gives this error. We even put it in the latter project's stdafx.h, right after the base include for MFC, and still no joy. We finally worked around it by moving it into a cpp file in the original project, which does not use MFC (which should have been done anyway - but it wasn't our code). So we've got a work-around, but no real solution.

0
votes

This error happens when you redeclare a variable of the same name as a variable that has already been declared. Have you looked to see if odbcss.h has declared a variable you already have?

0
votes

does this help?

http://bytes.com/forum/thread602063.html

Content from the thread:

Bruno van Dooren [MVP VC++] but i know the solution of this problem. it solves by changing project setting of "Treat wchar_t as Built-in Type" value "No (/Zc:wchar_t-)". But I am using "Xtreme Toolkit Professional Edition" for making good look & Feel of an application, when i fix the above problem by changing project settings a new linking errors come from Xtreme Toolkit Library. So what i do to fix this problem, in project setting "Treat wchar_t as Built-in Type" value "yes" and i wrote following statements where i included wab.h header file. You can change that setting on a per-codefile basis so that only specific files are compiled with that particular setting. If you can solve your problems that way it would be the cleanest solution.

#define WIN16

#include "wab.h"

#undef WIN16

and after that my project is working fine and all the things related to WAB is also working fine. any one guide me, is that the right way to solve this problem??? and, will this have any effect on the rest of project?? I wouldn't worry about it. whatever the definition, it is a 16 bit variable in both cases. I agree that it isn't the best looking solution, but it should work IF WIN16 has no other impact inside the wab.h file.

--

Kind regards, Bruno van Dooren [email protected] Remove only "_nos_pam"