aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Error on Format.cpp (x86_64)  (Read 4206 times)

wires

  • Jr. Member
  • **
  • Karma: 6
  • Offline Offline
  • Posts: 83
Error on Format.cpp (x86_64)
« on: December 09, 2008, 02:49:51 AM »

Hi,

I'm trying to compile aMule-SVN-r9248-RELEASE-2_2_X on Fedora 9 64 bits (AMD64) and I'm getting this error:
Code: [Select]
Format.cpp: In member function 'CFormat& CFormat::operator%(void*)':
Format.cpp:434: error: cast from 'void*' to 'uint32_t' loses precision

I think the `if' surrounding this statement should be replaced by a preprocessor condition #ifdef __LP64__ (and the win peer) to avoid compiling an invalid statement (else branch for 64bits arch). Or may be using size_t instead of a fixed type (uintXX_t)?
Logged

jpv950

  • Jr. Member
  • **
  • Karma: 2
  • Offline Offline
  • Posts: 59
Re: Error on Format.cpp (x86_64)
« Reply #1 on: December 09, 2008, 06:48:11 AM »

I came here to report about this too (Ubuntu Intrepid AMD64).

Meanwhile as a workaround you can comment out the broken if clause (for 64 bit systems only of course):

Code: [Select]
--- Format.cpp.old 2008-12-09 05:45:25.000000000 +0000
+++ Format.cpp 2008-12-09 05:40:23.000000000 +0000
@@ -428,11 +428,11 @@ CFormat& CFormat::operator%(void * value
  // - Windows: uppercase, no leading 0x
  // - Linux:   leading zeros missing
  // -> format it as hex
- if (sizeof (void *) == 8) { // 64 bit
+// if (sizeof (void *) == 8) { // 64 bit
  SetCurrentField(wxString::Format(wxT("0x%016x"), (uint64_t) value));
- } else { // 32 bit
- SetCurrentField(wxString::Format(wxT("0x%08x"), (uint32_t) value));
- }
+// } else { // 32 bit
+// SetCurrentField(wxString::Format(wxT("0x%08x"), (uint32_t) value));
+// }
  }
 
  return *this;
Logged

jpv950

  • Jr. Member
  • **
  • Karma: 2
  • Offline Offline
  • Posts: 59
Re: Error on Format.cpp (x86_64)
« Reply #2 on: December 09, 2008, 10:32:00 PM »

Here's a patch to fix this:

Code: [Select]
--- Format.cpp.old 2008-12-08 15:11:46.000000000 +0000
+++ Format.cpp 2008-12-09 21:30:24.000000000 +0000
@@ -429,9 +429,9 @@ CFormat& CFormat::operator%(void * value
  // - Linux:   leading zeros missing
  // -> format it as hex
  if (sizeof (void *) == 8) { // 64 bit
- SetCurrentField(wxString::Format(wxT("0x%016x"), (uint64_t) value));
+ SetCurrentField(wxString::Format(wxT("0x%016x"), (uintptr_t) value));
  } else { // 32 bit
- SetCurrentField(wxString::Format(wxT("0x%08x"), (uint32_t) value));
+ SetCurrentField(wxString::Format(wxT("0x%08x"), (uintptr_t) value));
  }
  }
Logged

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: Error on Format.cpp (x86_64)
« Reply #3 on: December 11, 2008, 09:27:35 PM »

Commited, thank you very much.  :)
Duh, I'm falling from hole into the next with this thingy. Now I'm waiting for someone saying "uintptr_t is undefined on my machine"...
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

jpv950

  • Jr. Member
  • **
  • Karma: 2
  • Offline Offline
  • Posts: 59
Re: Error on Format.cpp (x86_64)
« Reply #4 on: December 11, 2008, 11:07:54 PM »

Glad to help.  :)

Yeah I considered that, I believe "uintptr_t" is defined in C99 (not sure about C++ compatibility there) so some non-compliant compilers may throw errors, but this is a very simple to implement and widespread part of the standard. I don't expect it to cause more breakage (hopefully).

Cheers.

EDIT: Duh myself, those are the same requirements as uintXX_t, so nevermind the overly elaborate and completely unnecessary comment above. ;)
« Last Edit: December 11, 2008, 11:25:28 PM by jpv950 »
Logged

FreeToGo

  • Jr. Member
  • **
  • Karma: 3
  • Offline Offline
  • Posts: 65
Re: Error on Format.cpp (x86_64)
« Reply #5 on: December 12, 2008, 04:09:32 AM »

changed to "uintptr_t"  works for Intrepid(AMD64).

Commited, thank you very much.  :)
Duh, I'm falling from hole into the next with this thingy. Now I'm waiting for someone saying "uintptr_t is undefined on my machine"...
Logged
You can mock me. I can take it.