note that integerPrintfMacros.h is incompatible with NSPR printf-like functions

RESOLVED FIXED in Firefox 42



3 years ago
3 years ago


(Reporter: oliver.henshaw, Assigned: oliver.henshaw)



Firefox Tracking Flags

(firefox42 fixed)



(1 attachment, 1 obsolete attachment)



3 years ago
I wanted to log a PRTime using mozilla/Logging.h and thought that integerPrintfMacros.h would allow me to specify a portable format string, i.e. PRId64.

But it didn't work and indeed "%ld" gave the same nonsense value. Only "%lld" worked as expected. After a while I realised this was by design, the logging functions use prlog.h and nspr defines its own set of printf-like functions with a different definition of format strings to that in C99, as noted in nsprpub/pr/include/prprf.h

Comment 1

3 years ago
Created attachment 8636717 [details] [diff] [review]
Add note warning about incompatibility with NSPR printf-like functions


3 years ago
Attachment #8636717 - Flags: review?(nfroyd)
Comment on attachment 8636717 [details] [diff] [review]
Add note warning about incompatibility with NSPR printf-like functions

Review of attachment 8636717 [details] [diff] [review]:

r=me with the change below.

::: mfbt/IntegerPrintfMacros.h
@@ +9,5 @@
>  #ifndef mozilla_IntegerPrintfMacros_h_
>  #define mozilla_IntegerPrintfMacros_h_
>  /*
> + * Intended for use with libc's printf function family. Should not be used with

I think it's a bit redundant to include the bit about libc.  How about:

"NB: These macros should not be used with the NSPR printf-like functions or their users, e.g. mozilla/Logging.h.  If you need to use NSPR's facilities, see the comment on supported formats at the top of nsprpub/pr/include/prprf.h."
Attachment #8636717 - Flags: review?(nfroyd) → review+

Comment 3

3 years ago
Created attachment 8639380 [details] [diff] [review]
Note incompatibility with NSPR printf-like functions.
Attachment #8636717 - Attachment is obsolete: true

Comment 4

3 years ago
No try run needed as it's a comment only change and I definitely haven't fat-fingered the keyboard.
Keywords: checkin-needed
Assignee: nobody → oliver.henshaw
Last Resolved: 3 years ago
status-firefox42: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
You need to log in before you can comment on or make changes to this bug.