Because you don't know the underlying type of, say, uint32_t, it's historically 
been difficult to printf them.  Common approaches included just assuming %u 
would work (and wouldn't generate format-mismatch compiler warnings), or using 
%lu and casting to (unsigned long).  Bleh.

C99's <inttypes.h> has macros that expand to string literals like "lu", that's 
supposed to be used for printf'ing <stdint.h> integers.  But of course it's not 
portable across platforms.  (No points for guessing which one doesn't have it.)

mfbt has a new header, IntegerPrintfMacros.h, that addresses this need.  It 
implements the <inttypes.h> interface, as far as these macros are concerned.  
So you should use it if you want to print <stdint.h> integers, now.

Slightly more detail here if you want it:

http://whereswalden.com/2013/09/04/mozillaintegerprintfmacros-h-now-provides-prid32-and-friends-macros-for-printfing-uint32_t-and-so-on/

Jeff
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to