www.digitalmars.com         C & C++   DMDScript  

c++ - namespaces and -Error: ambiguous reference to symbol

reply "Tom Lowe" <talowe tmynetplus.com> writes:
Similar to what STLport does to pull global functions into std::

//test.cpp - test namespace
//global function
void testfunc(void){}

//pull into namespace
namespace myname{
 using ::testfunc;
};


//use in namespace
namespace myname{
 void func(void){
   testfunc(); // Error: ambiguous reference to symbol
 }
};

int main(void){
 myname::func();
 return 1;
};

output:

sc    test.cpp
test3 testfunc(); //Error: ambiguous reference to symbol ^ test.cpp(13) : Error: ambiguous reference to symbol Had: testfunc() and: testfunc() --- errorlevel 1
Exit code: 1
Borland compiles cleanly.
bcc32    test.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland test.cpp: Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Exit code: 0
Apr 16 2002
parent reply "Walter" <walter digitalmars.com> writes:
DMC doesn't do the so-called "Koenig lookup" on namespaces. It will, but
until then, probably the easiest thing is to use the STL included with DMC.

"Tom Lowe" <talowe tmynetplus.com> wrote in message
news:a9inco$1acd$2 digitaldaemon.com...
 Similar to what STLport does to pull global functions into std::

 //test.cpp - test namespace
 //global function
 void testfunc(void){}

 //pull into namespace
 namespace myname{
  using ::testfunc;
 };


 //use in namespace
 namespace myname{
  void func(void){
    testfunc(); // Error: ambiguous reference to symbol
  }
 };

 int main(void){
  myname::func();
  return 1;
 };

 output:

sc    test.cpp
test3 testfunc(); //Error: ambiguous reference to symbol ^ test.cpp(13) : Error: ambiguous reference to symbol Had: testfunc() and: testfunc() --- errorlevel 1
Exit code: 1
Borland compiles cleanly.
bcc32    test.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland test.cpp: Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Exit code: 0
Apr 16 2002
parent "Tom Lowe" <talowe tmynetplus.com> writes:
"Walter" <walter digitalmars.com> wrote in message
news:a9j2vh$2h7f$1 digitaldaemon.com...
 DMC doesn't do the so-called "Koenig lookup" on namespaces. It will, but
 until then, probably the easiest thing is to use the STL included with
DMC. Was hoping I could use stlport to pull standard functions into std::, just have to wait. Thanks for the reply Tom Lowe talowe mynetplus.com
Apr 17 2002