Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » what's wrong
what's wrong [message #8187] Thu, 15 February 2007 09:56 Go to next message
Ulti is currently offline  Ulti
Messages: 108
Registered: September 2006
Experienced Member
void App::ExcelIt()
{
Vector<byte> s;
int32 val;
s.Add(0x0);s.Add(0x0);
s.Add(0x0);s.Add(0x01);
EndianRW::Endian::Read(s,val,0,false);
PromptOK(AsString(val));
}

namespace EndianRW
{
using namespace Upp;
struct Endian
{
template<typename Type>
static void Read(const Vector<byte>&from,Type& retVal,int32 pos=0,int32 bytes=0,bool LE=true)
{
retVal=Type(0);
if(0==bytes) bytes=sizeof(Type);
for(int32 i=0;i<bytes;++i)
{
retVal|=(LE?(((Type)((byte)from[pos+i]))<<8*i)Sad((Type)((byte)from[pos+i]))<<8*(bytes-i-1)));
}
}
};
}


MSC7.1 windowsXP
Error messages:
d:\Ulti\MyApps\OPath\UEndian.h(15) : error C2666: 'Upp::Vector<T>::operator`[]'' : 2 overloads have similar conversions
with
[
T=Upp::byte
]
D:\Ulti\upp\uppsrc\Core\Vcont.h(32): could be 'const Upp::byte &Upp::Vector<T>::operator [](int) const'
with
[
T=Upp::byte
]
or 'built-in C++ operator[(Upp::byte , Upp::int32)'
while trying to match the argument list '(const Upp::Vector<T>, Upp::int32)'
with
[
T=Upp::byte
]
D:\Ulti\MyApps\OPath\main.cpp(128) : see reference to function template instantiation 'void EndianRW::Endian::Read<Upp::int32>(const
Upp::Vector<T> &,Type &,Upp::int32,Upp::int32,bool)' being compiled
with
[
T=Upp::byte,
Type=Upp::int32
]
d:\Ulti\MyApps\OPath\UEndian.h(15) : error C2666: 'Upp::Vector<T>::operator`[]'' : 2 overloads have similar conversions
with
[
T=Upp::byte
]
D:\Ulti\upp\uppsrc\Core\Vcont.h(32): could be 'const Upp::byte &Upp::Vector<T>::operator [](int) const'
with
[
T=Upp::byte
]
or 'built-in C++ operator[(Upp::byte , Upp::int32)'
while trying to match the argument list '(const Upp::Vector<T>, Upp::int32)'
with
[
T=Upp::byte
]
OPath: 1 file(s) built in (0:02.27), 2274 msecs / file, duration = 2284 msecs

There were errors. (0:02.70)


compiled with MINGW32 passed


Re: what's wrong [message #8216 is a reply to message #8187] Tue, 20 February 2007 08:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, those are these subtle C++ overloading rules that are so often broken by specific compiler implementation.

To make it clear for both compilers, typecast index to 'int'.

.... retVal|=(LE?(((Type)((byte)from[int(pos+i)])) ....

Mirek
Re: what's wrong [message #8219 is a reply to message #8216] Tue, 20 February 2007 12:27 Go to previous message
Ulti is currently offline  Ulti
Messages: 108
Registered: September 2006
Experienced Member
thanks,I already changed pos and i to int,compiled ok.
Razz
Previous Topic: Assmbley with Upp
Next Topic: Show the registers when debugging
Goto Forum:
  


Current Time: Thu Apr 18 10:03:03 CEST 2024

Total time taken to generate the page: 0.02259 seconds