aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Compiling Errors on DownloadClient.cpp  (Read 5872 times)

FreeToGo

  • Jr. Member
  • **
  • Karma: 3
  • Offline Offline
  • Posts: 65
Compiling Errors on DownloadClient.cpp
« 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);



« Last Edit: December 04, 2008, 04:17:04 PM by FreeToGo »
Logged
You can mock me. I can take it.

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Compiling Errors on DownloadClient.cpp
« Reply #1 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.)
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: Compiling Errors on DownloadClient.cpp
« Reply #2 on: December 04, 2008, 09:34:46 PM »

Stu, please implement %p on CFormat.
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Compiling Errors on DownloadClient.cpp
« Reply #3 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.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: Compiling Errors on DownloadClient.cpp
« Reply #4 on: December 04, 2008, 11:57:41 PM »

%p usually prints the 0x prefix.
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Compiling Errors on DownloadClient.cpp
« Reply #5 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.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: Compiling Errors on DownloadClient.cpp
« Reply #6 on: December 05, 2008, 12:30:26 AM »

:( My bad. Add it to the string, tho
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: Compiling Errors on DownloadClient.cpp
« Reply #7 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.
Logged
concordia cum veritate

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: Compiling Errors on DownloadClient.cpp
« Reply #8 on: December 05, 2008, 11:15:22 AM »

Yeah, it seemed strange to me too that I was wrong at anything.
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: Compiling Errors on DownloadClient.cpp
« Reply #9 on: December 05, 2008, 02:09:46 PM »

Yeah, it seemed strange to me too that I was wrong at anything.
XD
Logged
concordia cum veritate

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Compiling Errors on DownloadClient.cpp
« Reply #10 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 ?
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

FreeToGo

  • Jr. Member
  • **
  • Karma: 3
  • Offline Offline
  • Posts: 65
Re: Compiling Errors on DownloadClient.cpp
« Reply #11 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.
Logged
You can mock me. I can take it.

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: Compiling Errors on DownloadClient.cpp
« Reply #12 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.
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Compiling Errors on DownloadClient.cpp
« Reply #13 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.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon