Re: Compiling under AMD64 fails

"Peter T. Breuer" <[email protected]> Wed, 26 Sep 2007 23:08:50 +0200 (CEST)
Newsgroups gmane.linux.enbd.general
Message-ID <[email protected]>
Following on the discussion about the error messages on enbd 2.4.33 when
compiling for amd64 (I believe I cautiously and harmlessly patched that
away but I've only confirmed it still works fine for ia32), I see this
interesting related item on the kernel list:


   Re: [PATCH] Since we have counters in __u64 

   > > __u64 is not always long long.
   >
   > What is the maximum size of long long across all architectures?
   > How does one format __u64 for printing?

   With %lu you get warnings when u64 is long long (32-bit).
   With %llu you get warnings when u64 is plain long (most 64-bit).

   Hence %llu + long long cast, i.e.:
   printf("%llu", (unsigned long long)value);

   This is ugly but luckily imposes no runtime overheads on
   current 32- or 64-bit machines.

   This could be done more cleanly if the u64 typedef also
   #define:d a corresponding FMT_U64 format string.

and

   In user space, use the macro PRIu64 (or PRIx64 etc) from <inttypes.h>.


I've no intention of using a macro that seems to be so special. I more
or less just cast everything to long long for printing and formated it
as %Ld. That seems to do it ("long" is 64bit on amd64, as I recall, and
so is "long long", but one can't pass one off as the other to printf -
but casting long to long long is OK).

With luck I'll get an arm machine to work on too soon.  Gah!

Peter