aMule Forum

English => Compilation problems => Topic started by: FreeToGo on December 04, 2008, 03:47:52 PM

Title: Compiling Errors on DownloadClient.cpp
Post 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);



Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Stu Redman on December 04, 2008, 09:26:17 PM
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.)
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Kry on December 04, 2008, 09:34:46 PM
Stu, please implement %p on CFormat.
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Stu Redman on December 04, 2008, 11:10:46 PM
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
Code: [Select]
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.
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Kry on December 04, 2008, 11:57:41 PM
%p usually prints the 0x prefix.
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Stu Redman on December 05, 2008, 12:19:11 AM
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.
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Kry on December 05, 2008, 12:30:26 AM
:( My bad. Add it to the string, tho
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: GonoszTopi on December 05, 2008, 10:58:13 AM
Quote from: man 3 printf
       #      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.
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Kry on December 05, 2008, 11:15:22 AM
Yeah, it seemed strange to me too that I was wrong at anything.
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: GonoszTopi on December 05, 2008, 02:09:46 PM
Yeah, it seemed strange to me too that I was wrong at anything.
XD
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Stu Redman on December 05, 2008, 06:24:53 PM
 ;D
Code: [Select]
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
Code: [Select]
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 ?
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: FreeToGo on December 05, 2008, 08:11:41 PM

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
Code: [Select]
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.
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Kry on December 05, 2008, 08:34:10 PM
It's a debug message, for all that's sacred, make it have a 0x.

As for CFormat, I'd say 0x too.
Title: Re: Compiling Errors on DownloadClient.cpp
Post by: Stu Redman on December 05, 2008, 10:59:56 PM
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.