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++ - Error: ambiguous reference to symbol

↑ ↓ ← "Alex Vinokur" <alexvn connect.to> writes:
===========================================
Digital Mars C/C++ Compiler Version 8.40.2n
===========================================


DMC has a problem with the following program.

====== C++ code : File foo.cpp : BEGIN ======

#include <string>
using namespace std;

template <class T>
int operator!=(const T& x, const T& y)
{
  return !(x == y);
}

int main ()
{
const string str;
  return 0;
}

====== C++ code : File foo.cpp : END ========

====== Compilation : BEGIN ======

$ dmc -I. -IC:/dm/stlport/stlport foo.cpp

C:/dm/stlport/stlport\stl/_algobase.c(221) : Error: ambiguous reference to
symbol
Had: operator !=(const T&,const T&)
and: std::operator !=(const _Tp&,const _Tp&)
C:/dm/stlport/stlport\stl/_algobase.c(234) : Error: ambiguous reference to
symbol
Had: operator !=(const T&,const T&)
and: std::operator !=(const _Tp&,const _Tp&)
C:/dm/stlport/stlport\stl/_algobase.c(235) : Error: ambiguous reference to
symbol
Had: operator !=(const T&,const T&)
and: std::operator !=(const _Tp&,const _Tp&)
C:/dm/stlport/stlport\stl/_algobase.c(240) : Error: ambiguous reference to
symbol
Had: operator !=(const T&,const T&)
and: std::operator !=(const _Tp&,const _Tp&)
C:/dm/stlport/stlport\stl/_string.c(392) : Error: ambiguous reference to symbol
Fatal error: too many errors
--- errorlevel 1

====== Compilation : END ========


--
   Alex Vinokur
     mailto:alexvn connect.to
     http://mathforum.org/library/view/10978.html
Mar 18 2004
→ "Anton Sekeris" <no.spam inter.nl.net> writes:
Walter,

Alex' problem might be stemming from the same issue as the one I
reported in C++.beta under subject 'namespace bug?' on 2004/02/18.

Kind regards,
Anton Sekeris.


Alex Vinokur wrote:

 
 ===========================================
 Digital Mars C/C++ Compiler Version 8.40.2n
 ===========================================
 
 
 DMC has a problem with the following program.
 
 ====== C++ code : File foo.cpp : BEGIN ======
 
 #include <string>
 using namespace std;
 
 template <class T>
 int operator!=(const T& x, const T& y)
 {
   return !(x == y);
 }
 
 int main ()
 {
 const string str;
   return 0;
 }
 
 ====== C++ code : File foo.cpp : END ========
 
 ====== Compilation : BEGIN ======
 
 $ dmc -I. -IC:/dm/stlport/stlport foo.cpp
 
 C:/dm/stlport/stlport\stl/_algobase.c(221) : Error: ambiguous
 reference to symbol Had: operator !=(const T&,const T&)
 and: std::operator !=(const _Tp&,const _Tp&)
 C:/dm/stlport/stlport\stl/_algobase.c(234) : Error: ambiguous
 reference to symbol Had: operator !=(const T&,const T&)
 and: std::operator !=(const _Tp&,const _Tp&)
 C:/dm/stlport/stlport\stl/_algobase.c(235) : Error: ambiguous
 reference to symbol Had: operator !=(const T&,const T&)
 and: std::operator !=(const _Tp&,const _Tp&)
 C:/dm/stlport/stlport\stl/_algobase.c(240) : Error: ambiguous
 reference to symbol Had: operator !=(const T&,const T&)
 and: std::operator !=(const _Tp&,const _Tp&)
 C:/dm/stlport/stlport\stl/_string.c(392) : Error: ambiguous reference
 to symbol Fatal error: too many errors
 --- errorlevel 1
 
 ====== Compilation : END ========
 
 
 --
    Alex Vinokur
      mailto:alexvn connect.to
      http://mathforum.org/library/view/10978.html

Mar 18 2004
"Walter" <walter digitalmars.com> writes:
The problem is there's a template in std which matches the template you
defined in the global namespace. By bringing std's symbol table into the
global namespace, then there's a conflict. This is not a bug in DMC++.

"Alex Vinokur" <alexvn connect.to> wrote in message
news:c3c9cn$aov$1 digitaldaemon.com...
 ===========================================
 Digital Mars C/C++ Compiler Version 8.40.2n
 ===========================================


 DMC has a problem with the following program.

 ====== C++ code : File foo.cpp : BEGIN ======

 #include <string>
 using namespace std;

 template <class T>
 int operator!=(const T& x, const T& y)
 {
   return !(x == y);
 }

 int main ()
 {
 const string str;
   return 0;
 }

 ====== C++ code : File foo.cpp : END ========

 ====== Compilation : BEGIN ======

 $ dmc -I. -IC:/dm/stlport/stlport foo.cpp

 C:/dm/stlport/stlport\stl/_algobase.c(221) : Error: ambiguous reference to

 Had: operator !=(const T&,const T&)
 and: std::operator !=(const _Tp&,const _Tp&)
 C:/dm/stlport/stlport\stl/_algobase.c(234) : Error: ambiguous reference to

 Had: operator !=(const T&,const T&)
 and: std::operator !=(const _Tp&,const _Tp&)
 C:/dm/stlport/stlport\stl/_algobase.c(235) : Error: ambiguous reference to

 Had: operator !=(const T&,const T&)
 and: std::operator !=(const _Tp&,const _Tp&)
 C:/dm/stlport/stlport\stl/_algobase.c(240) : Error: ambiguous reference to

 Had: operator !=(const T&,const T&)
 and: std::operator !=(const _Tp&,const _Tp&)
 C:/dm/stlport/stlport\stl/_string.c(392) : Error: ambiguous reference to

 Fatal error: too many errors
 --- errorlevel 1

 ====== Compilation : END ========


 --
    Alex Vinokur
      mailto:alexvn connect.to
      http://mathforum.org/library/view/10978.html

Mar 18 2004
↑ ↓ "Alex Vinokur" <alexvn connect.to> writes:
"Walter" <walter digitalmars.com> wrote in message
news:c3du2o$4tn$2 digitaldaemon.com...
 The problem is there's a template in std which matches the template you
 defined in the global namespace. By bringing std's symbol table into the
 global namespace, then there's a conflict. This is not a bug in DMC++.

So, what to do? P.S. GNU g++ 3.3.1, Microsoft C++ 13.00.9466, Borland C++ 5.5.1 have no problem with that code. -- Alex Vinokur mailto:alexvn connect.to http://mathforum.org/library/view/10978.html
Mar 18 2004
↑ ↓ → "Walter" <walter digitalmars.com> writes:
"Alex Vinokur" <alexvn connect.to> wrote in message
news:c3e0io$a15$1 digitaldaemon.com...
 "Walter" <walter digitalmars.com> wrote in message

 The problem is there's a template in std which matches the template you
 defined in the global namespace. By bringing std's symbol table into the
 global namespace, then there's a conflict. This is not a bug in DMC++.

So, what to do?

Decide which version of the template you wish to use, and either delete the other one or turn off importing the namespace.
 P.S. GNU g++ 3.3.1, Microsoft C++ 13.00.9466, Borland C++ 5.5.1 have no

It's not the first time DMC++ is the only compiler that gets it right!
Mar 18 2004