PRB: C2371 BSTR Redefinition When VFW.H Included in MFC App

Last reviewed: July 2, 1997
Article ID: Q129953
2.00 2.10 3.50 WINDOWS NT kbmm kbprb kberrmsg

The information in this article applies to:

  • Microsoft Win32 Software Development Kit (SDK), version 3.5
  • Microsoft Visual C++, 32-bit Edition, versions 2.0 and 2.1

SYMPTOMS

The following error message occurs when compiling an application with Microsoft Visual C++, version 2.0 or 2.1, which uses the Microsoft Video for Windows header file, VFW.H, and the Microsoft Foundation Classes (MFC):

   c:\msvc20\include\oleauto.h(214) : error C2371: 'BSTR' : redefinition;
   different basic types

This error message does not occur when using Microsoft Visual C++ version 1.5 for Windows with the Microsoft Video for Windows 1.1 DK installed while running under Microsoft Windows operating system version 3.1.

RESOLUTION

If the application does not require binary string (BSTR) support you can eliminate this error message by defining "_AFX_NO_BSTR_SUPPORT" before the MFC include files. For example, place the code below at the beginning of the STDAFX.H file:

   #define _AFX_NO_BSTR_SUPPORT

If the application does require BSTR support, then you can eliminate this error message by including the code below before including the VFW.H file:

   #define OLE2ANSI

MORE INFORMATION

This error message occurs by design. MFC versions 3.0 and 3.1 require either that "OLE2ANSI" is defined when including the object linking and embedding (OLE) headers or that "_AFX_NO_BSTR_SUPPORT" is defined. You cannot use both ANSI-BSTRs (which is the default) and Unicode-BSTRs; you must use one or the other.

The AFX.H file defines the BSTR type in order to allow CStrings to support BSTRs. The VFW.H file unconditionally includes the OLE2.H file, which eventually includes the OLEAUTO.H file, which also defines the BSTR type. "_AFX_NO_BSTR_SUPPORT" disables CString support for BSTRs.

Steps to Reproduce Problem

  1. Generate a default application with AppWizard.
2. Add the statement "#include vfw.h" to the end of the STDAFX.H file. 3. Compile the application.

The VFW.H file is included with the Microsoft Visual C++, 32-bit Edition, and the Microsoft Win32 SDK for Windows NT.


Additional reference words: 3.10 3.50 2.00 2.10 CString port porting VfWDK
KBCategory: kbmm kbprb kberrmsg
KBSubcategory: MMVIDEO
Technology : kbMfc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.