This is thoroughly frustrating.  I just tried both methods that worked
for you, and go ahead and guess, they worked fine for me.

Evidently there was some subtle difference that I missed the first
time.


On Wed, 9 Oct 2002 13:05:17 +0200, John Marshall <[EMAIL PROTECTED]>
wrote:

>
>On Thu, Oct 03, 2002 at 05:43:38AM -0500, Michael Harrison wrote:
>> TraceOutput( TL( appErrorClass, "re-allocated %hu bytes of record
>> memory", gNumRecordsAllocated * sizeof(UInt16) ) );
>
>The sizeof operator returns a size_t, which, on Palm OS with both GCC
>and CodeWarrior, is the same size as a long.  So your code is wrong: you
>should be using %lu instead.
>
>Rather than trying to remember how big a size_t is, when passing one
>to a varargs function like printf it's a common idiom to cast it to
>something known, as you have done:
>
>> TraceOutput( TL( appErrorClass, "re-allocated %hu bytes of record
>> memory", UInt16(gNumRecordsAllocated * sizeof(UInt16)) ) );
>
>or to use an explicit temporary:
>
>> UInt16 BytesAlloc = gNumRecordsAllocated * sizeof(UInt16);
>> TraceOutput( TL( appErrorClass, "re-allocated %hu bytes of record
>> memory", BytesAlloc ) );
>
>Both of these produced the appropriately sized argument for %hu for me.
>I was unable to reproduce the problem you say you had with the former.
>
>    John
>


  Michael S. Harrison
  michaelh.dragonseye@com
  (reverse the dot and at to send email)

* The opinions expressed here are those of my iguana
* and I never know what he's going to say next.

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to