www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

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

↑ ↓ ← "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

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

test.cpp: Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Exit code: 0

Apr 16 2002
↑ ↓ "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

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

test.cpp: Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Exit code: 0


Apr 16 2002
↑ ↓ → "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

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