DOCUMENT:Q167323 04-AUG-2001 [visualc] TITLE :BUG: Compiler Error C2955 Caused by Global STL Iterators PRODUCT :Microsoft C Compiler PROD/VER:4.2 OPER/SYS: KEYWORDS:kbcode kbProgramming kbLangCPP kbVCkbbuglist ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual C++, 32-bit Enterprise Edition, version 4.2 - Microsoft Visual C++, 32-bit Professional Edition, version 4.2 ------------------------------------------------------------------------------- SYMPTOMS ======== When you declare a global typedef of any STL iterator, the compiler error C2955 occurs. RESOLUTION ========== In the sample code below, replace: typedef IntVector::iterator IT ; with the following code: // Workaround for VC++ 4.2: #if _MSC_VER == 1020 struct X { typedef IntVector::iterator it ; }; typedef X::it IT ; #else typedef IntVector::iterator IT ; #endif STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available. MORE INFORMATION ================ Sample Code ----------- /* Compile options needed: /GX */ #include #include typedef vector > IntVector; // C2955 error on the following line typedef IntVector::iterator IT ; void Show (IT i) { cout << *i << endl; } int main (int argc, char *argv[]) { IntVector v; v.push_back(1); v.push_back(2); v.push_back(3); for (IntVector::iterator i = v.begin(); i != v.end(); i++) { Show(i); } return 0 ; } Additional query words: STL iterator ====================================================================== Keywords : kbcode kbProgramming kbLangCPP kbVC kbbuglist Technology : kbVCsearch kbAudDeveloper kbVC420 kbVC32bitSearch Version : 4.2 Issue type : kbbug ============================================================================= 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. Copyright Microsoft Corporation 2001.