BUG: Same Name for Function and Class Causes C2079Last reviewed: April 24, 1997Article ID: Q167356  | 
	
	
 
 
The information in this article applies to:
 
 SYMPTOMSIf a single name refers to both a class name and a function name, errors similar to the following may be incorrectly generated: 
    error C2079: 'g1' uses undefined struct 'g'
   error C2875: using-declaration causes a multiple declaration of 'A::x'
   error C2513: 'struct B::x' : decl-specifier is missing a declarator
                before '='
RESOLUTIONReplace the using declaration with a using directive. For example, in the following code replace the using declarations: 
 using B::f using B::g using B::xwith one: 
 using namespace B;Look at the More Information section for a sample that demonstrates the workaround. 
 STATUSMicrosoft 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 INFORMATIONSection 7.3.3, paragraph 10 of the 1997 C++ Public Review Document states: 
    If  the  set  of declarations and using-declarations for a single name
   are given in a declarative region,
   --they shall all refer to the same entity, or all refer to  functions;
     or
   --exactly  one  declaration  shall declare a class name or enumeration
     name and the other declarations shall all refer to the  same  entity
     or  all  refer to functions; in this case the class name or enumera-
     tion name is hidden."
Sample Code
     namespace A {
       int x;
    }
    namespace B {
       int i;
       struct g { };
       struct x { };
       void f(int);
       void f(double);
       void g(char);
    }
    void func()  {
       int i;
       void f(char);
       using B::f;
       f(3.5f);
       using B::g;
       g('a');
       struct g g1;     // error C2079
       using B::x;
       using A::x;     // error C2875
       x = 99;         // error C2513:
       struct x x1;
    }
    //Workaround
    namespace A {
       int x;
    }
    namespace B {
       int i;
       struct g { };
       struct x { };
       void f(int);
       void f(double);
       void g(char);
    }
    void func()  {
       using namespace B ;
       int i;
       void f(char);
       f(3.5f);
       g('a');
       struct g g1;
       using A::x;
       x = 99;
       struct x x1;
    }
 
	
	 | 
	
	Keywords : CLIss kbtool vcbuglist500 kbbuglist 
 © 1998 Microsoft Corporation. All rights reserved. Terms of Use.  |