FIX: C2593: "operatoLast reviewed: September 16, 1997Article ID: Q87640 |
The information in this article applies to:
SYMPTOMSIn an application that uses the Microsoft Foundation Classes, a statement intended to send a single character to the predefined afxDump stream cause the compiler to generate the following error message:
error C2593: 'operator <<' is ambiguous CAUSEIn C++, normal character constants have type "char," and multi-byte character constants have type "int." The afxDump stream has type "CDumpContext &"; therefore the compiler can choose either of the following versions of the "operator<<":
CDumpContext& operator<<(BYTE); // BYTE is an unsigned char CDumpContext& operator<<(int); RESOLUTIONTo eliminate this error message, use a string instead of using a single character. This same error occurs when an application attempts to serialize any type that is not specifically supported. For example, as the sample code below demonstrates, replace '\n' with a "\n". In that case, the code would choose the following operator<<:
CDumpContext& operator<<(const char FAR *); STATUSMicrosoft has confirmed this to be a problem in the Microsoft Foundation Classes versions 1.0 and 2.0 for MS-DOS and Windows. This problem was corrected in the Microsoft Foundation Classes version 2.0 for Windows NT.
MORE INFORMATIONThe following code demonstrates this situation. Be sure to link with the correct Microsoft Foundation Classes debugging library.
Sample Code
/* * Compiler options needed: /D_DEBUG, /D_DOS or /D_WINDOWS * / #include <afx.h> void main() { afxDump << "Hello, world." << '\n'; // To fix, comment this line // << "\n"; // and remove the comment from this line. } Keywords : kb16bitonly MfcFileIO kberrmsg Technology : kbmfc Version : 1.0 1.5 7.0 Platform : MS-DOS WINDOWS Issue type : kbbug Solution Type : kbfix |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |