www.digitalmars.com         C & C++   DMDScript  

c++ - bug? duplicate declaration?

reply 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
parent reply "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
parent reply 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)


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





[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
next sibling parent Anuj Goyal <Anuj_member pathlink.com> writes:


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





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
prev sibling next sibling parent reply "Walter" <newshound digitalmars.com> writes:
Looks like a compiler bug.
May 08 2005
parent 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
prev sibling parent "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)


 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





 [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