Microsoft KB Archive/155420

= Errors C2146, C2065, and C2143 occur when you compile code that includes consecutive closing chevrons (>>) at the end of the declaration in Visual C++ =

Article ID: 155420

Article Last Modified on 6/3/2005

-

APPLIES TO


 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 4.1 Subscription
 * Microsoft Visual C++ 4.2 Enterprise Edition
 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 4.2 Professional Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q155420





SYMPTOMS
The compiler generates error C2146 followed by C2065 and finally C2143, all pointing to the same line in the source.

This sequence of errors can be caused by the following type of construct: ClassA iA ; The problem is caused by the consecutive closing chevrons ">>" at the end of the declaration.



RESOLUTION
The solution is to put a space between the consecutive >>, so the above code becomes: ClassA iA ; This is not a compiler bug. The language specification requires the space between the two ">"; otherwise, the lexical parser generates the token ">>", which is the largest possible token.

Sample Code
//Compile options needed: none // test.cpp

template  class ClassB {} ;

template  class ClassA{} ;

void main {   ClassA iA; // causes C2146, C2065, C2143 //ClassA iA; //workaround

}

Keywords: kberrmsg kbtshoot kbprb kbcpponly kbcompiler KB155420

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.