BUG: C2065 in External Definition of Nested Member Function

Article ID: Q151586
Creation Date: 27-MAY-1996
Revision Date: 18-JUL-1996

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with: Microsoft Visual C++, 32-bit Edition, versions 2.0, 2.1, 2.2, 4.0, 4.1, 4.2

SYMPTOMS

An undeclared id error C2065 in the external definition of nested member function for parameters of user-defined type, enum, struct, and class in the enclosed scope appears when typedef is used.

RESOLUTION

Please refer to the More Information section of this article for a sample code and workarounds.

STATUS

Microsoft has confirmed this to be bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The following code reproduces the error when compiled. The undeclared identifier error is reported for the enum E declared in the enclosed scope. Declarations in global scope do not produce this error.

   //Compile option needed -- none

   struct A {

      enum E {e = 1};

      struct B{
               void g(int);
                   void f(E);
                };
    };

   typedef A::B  C;

   void C::g(int i){}
   void C::f(E e){}   // error C2065: 'E' : undeclared identifier

WORKAROUND
  • Define nested function internally. In the example, define function f(E) inside struct B.
  • Use C::f(A::E e) or, A::B::f(E e) for C::f(E e).


Additional reference words: 2.00 2.10 2.20 4.00 4.10 4.20 vcbuglist400
KBCategory: kbprg kbbuglist
KBSubcategory: CPPIss

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.

©1997 Microsoft Corporation. All rights reserved. Legal Notices.