Code migration from gcc to SunStudio C++

Hi

Am new to C++ and have a project on hands which requires migrating the existing code written for gcc 3.2 compiler to Sunstudio 11. When I try to compile the code with CC, I get an error -

Error: abc(const char*) already had a body defined

I am trying to overload a method, one having the parameter as "const char*" and the other having a parameter as std::string::const_iterator.

#include <string>

using namespace std;

int main()

{

}

void abc (const char* a){}

void abc (std::string::const_iterator ptr){}

Although this works fine with gcc as well as Visual Studio, there is a compilation error with Sun's CC. Since such definitions exist a lot many times in my existing code, it would be very time consuming and laborious task to change the code and the logic everywhere.

Is there any compiler option that can be used to make CC compatible with gcc code? Or apart from compiler option is there any other way I can get away with making changes throught my code?

Thanks in advance

[1075 byte] By [newbeecpp] at [2007-11-26 7:24:54]
# 1

The problem is in the std::string realization. std::string::const_iterator actually is typedef for const char *. So both functions have the same type of argument. As I remember the latest version of stlport library does not have that problem. You could take it here /http://sourceforge.net/projects/stlport.

Atanasyan at 2007-7-6 19:12:02 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
FWIW, this is not a problem in the implementation of the library. The type of std::whatever::iterator is not specified by the C++ standard and programs that make assumptions about it beyond those supported by Random Access Iterator Requirements are not portable.
sebor@roguewavecom at 2007-7-6 19:12:02 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

I agree - it's not a bug in the library implementation. I just want to say - it's not a bug in the compiler too. BTW the latest implementation of stlport still use const char * for constant_iterator.

What is the difference between two variant of abc function? I mean function body, not arguments. String iterator and pointer to char are very "similar" even if they actually are different types. Maybe it's a good time to refactor two version of abc and leave one common implementation?

Atanasyan at 2007-7-6 19:12:02 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
An one more hint. Try to comment out 'abc' like that:[code]void abc (const char* a){}#ifndef __SUNPRO_CCvoid abc (std::string::const_iterator ptr){}#endif[/code]That might work.
Atanasyan at 2007-7-6 19:12:02 > top of Java-index,Development Tools,Solaris and Linux Development Tools...