aMule Forum
English => Compilation problems => Topic started by: FreeToGo on December 04, 2008, 03:47:52 PM
-
I got the following errors on Intrepid (AMD64) but not on Intrepid (i386).
DownloadClient.cpp: In member function ‘float CUpDownClient::CalculateKBpsDown()’:
DownloadClient.cpp:1189: error: cast from ‘CUpDownClient*’ to ‘uint32’ loses precision
make[3]: *** [amule-DownloadClient.o] Error 1
I guess float->uint32 for 32bit OS but float->uint64 for 64bit OS. I suggest the following changes:
jc@jc-hp:~/Desktop/aMule-SVN-r9217-RELEASE-2_2_X/src$ diff DownloadClient.cpp DownloadClient.cpp~
1190c1190
< % (unsigned long)this % kBpsDown % kBpsDownCur % dt % bytesReceivedCycle);
---
> % (uint32)this % kBpsDown % kBpsDownCur % dt % bytesReceivedCycle);
-
Yeah, CFormat is missing the %p . :(
Please try if % (size_t)this % kBpsDown % kBpsDownCur % dt % bytesReceivedCycle);
also works, I'd prefer that.
Thanks for the report! (Please use the compilation problems board next time though.)
-
Stu, please implement %p on CFormat.
-
OK, done (9230). Yes, that's best.
FreeToGo, please check if it works on 64 bit too. Build with debug, Check Preferences/Debugging/ "Enable Verbose Debug-Logging" and "Local Client Protocol", wait until it downloads, then check the log for a line like
2008-12-04 22:54:24: DownloadClient.cpp(1190): Local Client Protocol: CalculateKBpsDown 02DA0A90 kbps 12,7 kbpsCur 17,6 dt 0,600 rcv 10840
and post it please.
-
%p usually prints the 0x prefix.
-
Are you sure ? wxString::Format() apparently doesn't. %x also doesn't. Neither does sprintf("%p") (just checked it). Probably because a 0x is easily added, but hard to remove.
-
:( My bad. Add it to the string, tho
-
# The value should be converted to an ``alternate form''. [...] For x and X conversions, a non-zero result has the string `0x' (or `0X' for X conversions) prepended to it.
p The void * pointer argument is printed in hexadecimal (as if by %#x or %#lx).
So, it should have a 0x prefix.
-
Yeah, it seemed strange to me too that I was wrong at anything.
-
Yeah, it seemed strange to me too that I was wrong at anything.
XD
-
;D
martin@hardy:~/aMule/test$ cat pr.c
#include <stdio.h>
int main() {
int i = 1000;
char buf[20];
sprintf(buf, "%p", &i);
printf("%p %x %s\n", &i, i, buf);
return 0;
}
martin@hardy:~/aMule/test$ gcc pr.c
martin@hardy:~/aMule/test$ ./a.out
0xbfd05268 3e8 0xbfd05268
2008-12-05 18:15:06: DownloadClient.cpp(1187): Local Client Protocol: CalculateKBpsDown 0x9aa6ca8 kbps 3.3 kbpsCur 3.4 dt 3.113 rcv 10833
U:\aMule\test>pr.exe
0012FF3C 3e8 0012FF3C
$ a.exe
0022FF3C 3e8 0022FF3C
So on Windows (MSVC and MinGW) it's no 0x and uppercase, on Linux it's 0x and lowercase. wx honors the platform peculiarities - CFormat and wxString::Format() behave different too. Thus Linux aMule already behaves like you want.
Now - keep the platform look or make it Linuxish? And anybody want to try Mac ?
-
Below is the log dump in Intrepid(AMD64):
2008-12-06 03:06:30: DownloadClient.cpp(1190): Local Client Protocol: CalculateKBpsDown 0x2efa670 kbps 1.1 kbpsCur 2.5 dt 4.262 rcv 10758
%p will print with ox prefix
jc@jc-hp:~/Desktop/aMule-SVN-r9232-RELEASE-2_2_X$ uname -a
Linux jc-hp 2.6.27-10-generic #1 SMP Fri Nov 21 19:19:18 UTC 2008 x86_64 GNU/Linux
FreeToGo
OK, done (9230). Yes, that's best.
FreeToGo, please check if it works on 64 bit too. Build with debug, Check Preferences/Debugging/ "Enable Verbose Debug-Logging" and "Local Client Protocol", wait until it downloads, then check the log for a line like
2008-12-04 22:54:24: DownloadClient.cpp(1190): Local Client Protocol: CalculateKBpsDown 02DA0A90 kbps 12,7 kbpsCur 17,6 dt 0,600 rcv 10840
and post it please.
-
It's a debug message, for all that's sacred, make it have a 0x.
As for CFormat, I'd say 0x too.
-
The debug message is not important, but %p is.
What is dumb about Linux %p: it prints no leading zeros. See above - you can't even see it's 64 bit. >:(
Guess I'll dump the wxString::Format() and format it as hex with 0x and leading zeros.