[CDRIVER-3810] Including bson-compat.h before inttypes.h may result in duplicate constant definitions Created: 27/Oct/20 Updated: 02/Nov/20 Resolved: 02/Nov/20 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | 1.9.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Kevin Albertson | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Reported in this comment of |
| Comments |
| Comment by Scott Willis [ 28/Oct/20 ] | |||
|
This is not a blocker for us at all, now that I know that adding #include <inttypes.h> before #include "bson.h" prevents it from manifesting. | |||
| Comment by Kevin Albertson [ 28/Oct/20 ] | |||
|
bson-stdint-win32.h was removed in
| |||
| Comment by Scott Willis [ 27/Oct/20 ] | |||
|
Title is currently incorrect; should say "before inttypes.h". | |||
| Comment by Scott Willis [ 27/Oct/20 ] | |||
|
The version we have #includes <stdint.h>; it does NOT #include <inttypes.h>. Snippet from bson-stdint-win32.h: | |||
| Comment by Scott Willis [ 27/Oct/20 ] | |||
|
Correction: <inttypes.h> not <stdint.h>! bson-compat.h does not #include <inttypes.h>. It does #include <stdint.h>, however <inttypes.h> is what defines PRIi32 etc. This issue is due to the following sequence:
Using Visual Studio 2017 and a version of inttypes.h that appears to be from a Windows 10? SDK; C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\inttypes.h. Build is done inside Visual Studio. Not sure what version of MongoDB the client has; bson.h, bson-compat.h show 2013 copyrights. _MSC_VER displayed as 1916. I do see: One possible (minimal) solution would be to #include <inttypes.h> in bson-compat.h, so that the standard definitions are already present before the possibly-conflicting #defines. | |||
| Comment by Kevin Albertson [ 27/Oct/20 ] | |||
|
scottw@attinc.com, bson-compat.h does attempt to include inttypes.h for non-Windows and VS 2013 or newer before conditionally defining those constants:
Perhaps that check is too conservative. Are you compiling with Visual Studio earlier than 2013? Additionally, can you include the cmake and build commands you are using to build, as well as the output and relevant warning? Thank you, |