[CDRIVER-2245] Macro redefinition of printf integer formats for VS2015 Created: 14/Aug/17  Updated: 28/Oct/23  Resolved: 12/Oct/17

Status: Closed
Project: C Driver
Component/s: libbson
Affects Version/s: 1.7.0
Fix Version/s: 1.9.0

Type: Task Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7, Visual Studio 2015


Issue Links:
Related
related to CDRIVER-1178 Reduce compiler warning flood on Windows Closed
related to CDRIVER-1191 Windows build error compiling libbson Closed
Epic Link: mongoc-toolchain

 Description   

I notice the following build warnings when compiling the PHPC 1.3.0 for PHP 7.x in Visual Studio 2015 (x64 and x86):

c:\php-sdk\phpdev\vc14\x64\pecl\mongodb\src\libbson\src\bson\bson-compat.h(115): warning C4005: 'PRIi32': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(130): note: see previous definition of 'PRIi32'
c:\php-sdk\phpdev\vc14\x64\pecl\mongodb\src\libbson\src\bson\bson-compat.h(118): warning C4005: 'PRIi64': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(131): note: see previous definition of 'PRIi64'
c:\php-sdk\phpdev\vc14\x64\pecl\mongodb\src\libbson\src\bson\bson-compat.h(119): warning C4005: 'PRId64': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(112): note: see previous definition of 'PRId64'
c:\php-sdk\phpdev\vc14\x64\pecl\mongodb\src\libbson\src\bson\bson-compat.h(120): warning C4005: 'PRIu64': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(169): note: see previous definition of 'PRIu64'

Would it be best to wrap these definitions in conditionals?



 Comments   
Comment by Scott Willis [ 27/Oct/20 ]

Hi @Kevin Albertson  I think there may be some confusion between inttypes.h and stdint.h.  The bson-compat.h I see #includes <stdint.h> but not <inttypes.h>.  In the Microsoft Windows dev kits, the PRI symbols are defined in <inttypes.h>.

Comment by Kevin Albertson [ 27/Oct/20 ]

Hi scottw@attinc.com, thank you for bringing that to our attention. I filed a new ticket, CDRIVER-3810 to investigate. If possible, can you comment on CDRIVER-3810 and include the system you are experiencing these warnings on? At least, looking at inttypes.h on my development machine, it includes checks for whether those constants are defined, so I do not get a duplicate definition warning.

Comment by Scott Willis [ 26/Oct/20 ]

Some of the constants defined in bson-compat.h overlap those #defined in inttypes.h.  Wrapping them in conditionals in bson-compat.h helps, however you will still get errors if bson.h (which #includes bson-compat.h) is #included before inttypes.h.  This is because inttypes.h will not yet have #defined the constants, so bson-compat.h will #define them, then (if #included) inttypes.h will #define them again.

Comment by Githook User [ 12/Oct/17 ]

Author:

{'email': 'kevin.eric.albertson@gmail.com', 'name': 'Kevin Albertson', 'username': 'kevinAlbs'}

Message: Merge pull request #204 from kevinAlbs/cdriver2245

CDRIVER-2245 Add conditionals around printf defines
Branch: master
https://github.com/mongodb/libbson/commit/ed989496749e79f132ebdab1dab4edb1dda2822f

Comment by Githook User [ 12/Oct/17 ]

Author:

{'email': 'kevin.albertson@10gen.com', 'name': 'Kevin Albertson', 'username': 'kevinAlbs'}

Message: CDRIVER-2245 Add conditionals around printf defines
Branch: master
https://github.com/mongodb/libbson/commit/e4b42a76ae4c127aeaea4c706b54c101ca9a8360

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