[CDRIVER-1368] libbson fprintf PRI specifiers for visual studio 2013 Created: 11/Jul/16  Updated: 24/Dec/16  Resolved: 24/Dec/16

Status: Closed
Project: C Driver
Component/s: libbson
Affects Version/s: 1.3.5
Fix Version/s: 1.6.0

Type: Bug Priority: Minor - P4
Reporter: Almansour Belleh Blanco [X] Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 64bit
Visual studio 2013



 Description   

Character string literals for the fprintf() and fwprintf() family of functions (PRIxxx) are declared differently in bson-compat.h and in inttypes.h.

bson-compat.h

  1. define PRIi32 "d"
  2. define PRId32 "d"
  3. define PRIu32 "u"
  4. define PRIi64 "I64i"
  5. define PRId64 "I64i"
  6. define PRIu64 "I64u"

inttypes.h

#define _PFX_8 "hh"
#define _PFX_16 "h"
#define _PFX_32 "l"
#define _PFX_64 "ll"

#define PRIi32 _PFX_32 "i"
#define PRId32 _PFX_32 "d"
#define PRIu32 _PFX_32 "u"
#define PRIi64 _PFX_64 "i"
#define PRId64 _PFX_64 "d"
#define PRIu64 _PFX_64 "u"



 Comments   
Comment by A. Jesse Jiryu Davis [ 24/Dec/16 ]

I believe this works as designed. MSVC supports format specifiers like "%I64i" since its early versions, whereas the specifiers like "%lld" are preferred for GCC and Clang. The msinttypes project, which has the same goal as our bson-compat.h for MSVC, also uses "%I64i" and similar macros, not "%lld". And finally, if you search for "PRId64" on this Wikipedia page:

https://en.wikipedia.org/wiki/Printf_format_string

... it says that "PRId64" is typically equivalent to I64d on Windows, although there is no reference cited.

Almansour is there a specific issue that our specifiers are causing? What unintended behavior do you observe?

Comment by A. Jesse Jiryu Davis [ 11/Jul/16 ]

Thanks for the report!

Generated at Wed Feb 07 21:12:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.