Microsoft KB Archive/87640

{|
 * width="100%"|

FIX: C2593: &quot;operato

 * }

Q87640

-- The information in this article applies to: - The Microsoft Foundation Classes (MFC), included with: - Microsoft C/C++, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0, 1.5 -- SYMPTOMS ======== In 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 CAUSE ===== In C++, normal character constants have type &quot;char,&quot; and multi-byte character constants have type &quot;int.&quot; The afxDump stream has type &quot;CDumpContext &&quot;; therefore the compiler can choose either of the following versions of the &quot;operator<<&quot;: CDumpContext& operator<<(BYTE); // BYTE is an unsigned char CDumpContext& operator<<(int); RESOLUTION ========== To 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 &quot;\n&quot;. In that case, the code would choose the following operator<<: CDumpContext& operator<<(const char FAR *); STATUS ====== Microsoft 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 INFORMATION ================ The 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 void main { afxDump << &quot;Hello, world.&quot; << '\n'; // To fix, comment this line // << &quot;\n&quot;; // and remove the comment from this line. }

Keywords : kberrmsg kb16bitonly kbFileIO kbMFC kbVC

Issue type : kbbug

Technology : kbAudDeveloper kbMFC