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++ - bug? duplicate declaration?

↑ ↓ ← Anuj Goyal <Anuj_member pathlink.com> writes:
xerces 2.6.0 has a file very similar to this:

#include <stdio.h>

class XMLString
{
public:
const wchar_t* findAny ();
wchar_t* findAny ();
private:
int a;
};

int main()
{
return 0;
}


C:\ws>dmc -cpp xmlstring.cpp
static wchar_t *findAny ();
^
xmlstring.cpp(7) : Error: 'XMLString::findAny' is already defined
--- errorlevel 1

g++ 3.3.3 does not err whist compiling.  Neither does xlc, aCC, or studio
May 07 2005
↑ ↓ "Walter" <newshound digitalmars.com> writes:
"Anuj Goyal" <Anuj_member pathlink.com> wrote in message
news:d5jshk$d55$1 digitaldaemon.com...
 xerces 2.6.0 has a file very similar to this:

 #include <stdio.h>

 class XMLString
 {
 public:
 const wchar_t* findAny ();
 wchar_t* findAny ();
 private:
 int a;
 };

 int main()
 {
 return 0;
 }


 C:\ws>dmc -cpp xmlstring.cpp
 static wchar_t *findAny ();
 ^
 xmlstring.cpp(7) : Error: 'XMLString::findAny' is already defined

The 'static' isn't in the example code??
 --- errorlevel 1

That's correct. After all, for: findAny(); how can the compiler tell which function to call?
May 07 2005
↑ ↓ Anuj Goyal <Anuj_member pathlink.com> writes:
my apologies, I posted the wrong code.... unfortunatley this one has more
complexity.

from XMLString.hpp (xerces 260)

### DMC
C:\ws>cat xmlstring.cpp
#include <stdio.h>

class XMLString
{
public:
static const char* findAny ( const char* const a, const char* const b);
static       char* findAny (       char* const a, const char* const b);
};

int
main ()
{
return 0;
}

C:\ws>dmc xmlstring.cpp
static       char* findAny (       char* const a, const char* const b);
^
xmlstring.cpp(7) : Error: 'XMLString::findAny' is already defined
--- errorlevel 1




### g++
[0305][u35354354 infong242:work]$
[0305][u35354354 infong242:work]$
[0305][u35354354 infong242:work]$ cat xmlstring.cpp
#include <stdio.h>

class XMLString
{
public:
static const char* findAny ( const char* const a, const char* const b);
static       char* findAny (       char* const a, const char* const b);
};

int main()
{
return 0;
}
[0305][u35354354 infong242:work]$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
[0305][u35354354 infong242:work]$ g++ xmlstring.cpp
[0305][u35354354 infong242:work]$

#no error


"Anuj Goyal" <Anuj_member pathlink.com> wrote in message
news:d5jshk$d55$1 digitaldaemon.com...
 xerces 2.6.0 has a file very similar to this:

 #include <stdio.h>

 class XMLString
 {
 public:
 const wchar_t* findAny ();
 wchar_t* findAny ();
 private:
 int a;
 };

 int main()
 {
 return 0;
 }


 C:\ws>dmc -cpp xmlstring.cpp
 static wchar_t *findAny ();
 ^
 xmlstring.cpp(7) : Error: 'XMLString::findAny' is already defined

The 'static' isn't in the example code??
 --- errorlevel 1

That's correct. After all, for: findAny(); how can the compiler tell which function to call?

May 08 2005
→ Anuj Goyal <Anuj_member pathlink.com> writes:
#### something with statics is causing a problem.

C:\ws>cat xmlstring.cpp
#include <stdio.h>

class XMLString
{
public:
static const char* findAny ( const char* const a);
static       char* findAny (       char* const a);
};

int
main ()
{
return 0;
}

C:\ws>dmc -cpp xmlstring.cpp
static       char* findAny (       char* const a);
^
xmlstring.cpp(7) : Error: 'XMLString::findAny' is already defined
--- errorlevel 1


##### with 'static' gone it compiles.


C:\ws>cat xmlstring.cpp
#include <stdio.h>

class XMLString
{
public:
const char* findAny ( const char* const a);
char* findAny (       char* const a);
};

int
main ()
{
return 0;
}

C:\ws>dmc -cpp xmlstring.cpp
link xmlstring,,,user32+kernel32/noi;
May 08 2005
"Walter" <newshound digitalmars.com> writes:
Looks like a compiler bug.
May 08 2005
↑ ↓ → Anuj Goyal <Anuj_member pathlink.com> writes:
can it be fixed? or is it a FOL (fact of life).

Looks like a compiler bug.

May 28 2005
→ "Matthew" <admin.hat stlsoft.dot.org> writes:
I've been experiencing similar const confusions with DMC++ in STLSoft, in terms
of making a pointer-to-const const 
itself, i.e.

    template <typename C>
    C const *someFunc(C const *s1, C const *const s2, C delim);

DMC++ fails to find an instantiation of someFunc() unless s2 is changed to be
"C const*".


"Anuj Goyal" <Anuj_member pathlink.com> wrote in message
news:d5kdso$q45$1 digitaldaemon.com...
 my apologies, I posted the wrong code.... unfortunatley this one has more
 complexity.

 from XMLString.hpp (xerces 260)

 ### DMC
 C:\ws>cat xmlstring.cpp
 #include <stdio.h>

 class XMLString
 {
 public:
 static const char* findAny ( const char* const a, const char* const b);
 static       char* findAny (       char* const a, const char* const b);
 };

 int
 main ()
 {
 return 0;
 }

 C:\ws>dmc xmlstring.cpp
 static       char* findAny (       char* const a, const char* const b);
 ^
 xmlstring.cpp(7) : Error: 'XMLString::findAny' is already defined
 --- errorlevel 1




 ### g++
 [0305][u35354354 infong242:work]$
 [0305][u35354354 infong242:work]$
 [0305][u35354354 infong242:work]$ cat xmlstring.cpp
 #include <stdio.h>

 class XMLString
 {
 public:
 static const char* findAny ( const char* const a, const char* const b);
 static       char* findAny (       char* const a, const char* const b);
 };

 int main()
 {
 return 0;
 }
 [0305][u35354354 infong242:work]$ g++ -v
 Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
 gcc version 2.95.4 20011002 (Debian prerelease)
 [0305][u35354354 infong242:work]$ g++ xmlstring.cpp
 [0305][u35354354 infong242:work]$

 #no error


"Anuj Goyal" <Anuj_member pathlink.com> wrote in message
news:d5jshk$d55$1 digitaldaemon.com...
 xerces 2.6.0 has a file very similar to this:

 #include <stdio.h>

 class XMLString
 {
 public:
 const wchar_t* findAny ();
 wchar_t* findAny ();
 private:
 int a;
 };

 int main()
 {
 return 0;
 }


 C:\ws>dmc -cpp xmlstring.cpp
 static wchar_t *findAny ();
 ^
 xmlstring.cpp(7) : Error: 'XMLString::findAny' is already defined

The 'static' isn't in the example code??
 --- errorlevel 1

That's correct. After all, for: findAny(); how can the compiler tell which function to call?


May 16 2005