views:

1229

answers:

4

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?

A: 

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?

Craig H
A: 

does this help?

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

John Boker
A: 

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.

Brian Stewart
+2  A: 

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.

ChrisN