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

RESOLVED FIXED in Firefox 42

Status

()

RESOLVED FIXED
3 years ago
3 years ago

People

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

Tracking

unspecified
mozilla42
Points:
---

Firefox Tracking Flags

(firefox42 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

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
(Assignee)

Comment 1

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

Updated

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+
(Assignee)

Comment 3

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

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
https://hg.mozilla.org/mozilla-central/rev/df688ddb5dbe
Assignee: nobody → oliver.henshaw
Status: UNCONFIRMED → RESOLVED
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.