ol muser
asked on
E2015 Builder Error C++
I have two the following two functions defined by someone else in the same file.
inline std::string NumberFormatter::format(in t value){//do something}
inline std::string NumberFormatter::format(un signed value) {//do something}
While they compile OK in VS2010, it produces the following error in Borland C++ Builder XE.
[BCC32 Error] DynamicAnyHolder.h(910): E2015 Ambiguity between 'Poco::NumberFormatter::fo rmat(int) at E:\Projects\PocoFoundation BDS\includ e\Poco/Num berFormatt er.h:384' and 'Poco::NumberFormatter::fo rmat(unsig ned int) at E:\Projects\PocoFoundation BDS\includ e\Poco/Num berFormatt er.h:426'
Why is that?
inline std::string NumberFormatter::format(in
inline std::string NumberFormatter::format(un
While they compile OK in VS2010, it produces the following error in Borland C++ Builder XE.
[BCC32 Error] DynamicAnyHolder.h(910): E2015 Ambiguity between 'Poco::NumberFormatter::fo
Why is that?
>>>>BCC32 Error] DynamicAnyHolder.h(910):
what is there in line 910?
it is just not possible for this error to happen. That would mean Borland's compiler doesn't support overloading
what is there in line 910?
it is just not possible for this error to happen. That would mean Borland's compiler doesn't support overloading
>> it is just not possible for this error to happen.
It could be, depending on what type of argument is being passed to the function.
It could be, depending on what type of argument is being passed to the function.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THis function is being called with an argument of Int8 (a typedef for signed char). Despite the faact that this function is called in many places with the same argument only these two occurences I have poted earlier seem to cause the ambiguity. And this seem to happen only with Borland CPP Builder. As an added note I am trying to compile a C++ library developed in VS using CPP Builder 2010.
>> THis function is being called with an argument of Int8 (a typedef for signed char).
Could you post the exact code ?
If it is in fact a signed char that is causing the ambiguity error, then that seems to be a problem with the compiler. A signed char should cause the int version of the function to be called.
Could you post the exact code ?
If it is in fact a signed char that is causing the ambiguity error, then that seems to be a problem with the compiler. A signed char should cause the int version of the function to be called.
ASKER
@Infinity08,
This is the function that causes the error:
void convert(std::string& val) const
{
val = NumberFormatter::format(_v al); //causes error
}
And this is how _val is defined:
private:
Int8 _val;
While the typedef reads
typedef signed char Int8;
This is the function that causes the error:
void convert(std::string& val) const
{
val = NumberFormatter::format(_v
}
And this is how _val is defined:
private:
Int8 _val;
While the typedef reads
typedef signed char Int8;
ASKER
Another instance where the same error occurs
[BCC32 Error] RegularExpression.cpp(308) : E2015 Ambiguity between '
Poco::RegularExpression::m atch(const std::basic_string<char,std ::char_tra its<char>, std::alloc ator<char> > &,unsigned int,int) const at src\RegularExpression.cpp: 160' and '
Poco::RegularExpression::m atch(const std::basic_string<char,std ::char_tra its<char>, std::alloc ator<char> > &,const std::basic_string<char,std ::char_tra its<char>, std::alloc ator<char> > &,int) at src\RegularExpression.cpp: 303'
The line that's causing the error is:
return re.match(subject,0, mtchOptions);
Seems like a difference in opinion between VS and Builder.
Appreciate deeper thoughts.
[BCC32 Error] RegularExpression.cpp(308)
Poco::RegularExpression::m
Poco::RegularExpression::m
The line that's causing the error is:
return re.match(subject,0, mtchOptions);
Seems like a difference in opinion between VS and Builder.
Appreciate deeper thoughts.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Infinity08, while I agree the explicit type cast would solve the issues, I am trying to understand the behaviour better (ref my original post).
Actually a simple test as below works fine (correct me if its not close to what I have posted earlier:
typedef signed char Int8;
class CTest {
public:
void f1(int value);
void f1(unsigned value);
}; //class CTest
inline void f1(int value) {}
inline void f1(unsigned value) {}
int _tmain(int argc, _TCHAR* argv[])
{
CTest c1;
Int8 _val;
c1.f1(_val);
return 0;
}
But the compiler seems happy with this!
Actually a simple test as below works fine (correct me if its not close to what I have posted earlier:
typedef signed char Int8;
class CTest {
public:
void f1(int value);
void f1(unsigned value);
}; //class CTest
inline void f1(int value) {}
inline void f1(unsigned value) {}
int _tmain(int argc, _TCHAR* argv[])
{
CTest c1;
Int8 _val;
c1.f1(_val);
return 0;
}
But the compiler seems happy with this!
>> Actually a simple test as below works fine (correct me if its not close to what I have posted earlier:
You seem to have forgotten the CTest:: namespace qualifier for the function definitions.
A difference with the original case also seems to be that Poco::NumberFormatter::for mat is a static member function, and CTest::f1 is a non-static member function.
>> But the compiler seems happy with this!
If after the above modifications, the compiler still doesn't throw an error for the test code, then maybe different compiler flags/options have been used for both cases ?
Or maybe the code that causes the error, is otherwise causing the ambiguity, in a part that you haven't shown ?
Or maybe the compiler is inconsistent ?
You seem to have forgotten the CTest:: namespace qualifier for the function definitions.
A difference with the original case also seems to be that Poco::NumberFormatter::for
>> But the compiler seems happy with this!
If after the above modifications, the compiler still doesn't throw an error for the test code, then maybe different compiler flags/options have been used for both cases ?
Or maybe the code that causes the error, is otherwise causing the ambiguity, in a part that you haven't shown ?
Or maybe the compiler is inconsistent ?
can you post the statement at line 910 of DynamicAnyHolder.h?
Sara
Sara
ASKER
@sarabande, here is the code:
void convert(std::string& val) const
{
910 val = NumberFormatter::format(_v al);
}
void convert(std::string& val) const
{
910 val = NumberFormatter::format(_v
}
olmuser, I wasn't aware that you still needed help with this. Could you let us know what it is that we can further help you with ?
It would help if you showed the code that is actually causing this warning (and more specifically the type of the argument passed to the function).