[CDRIVER-4451] Build error redefining bson_in_range_long_signed in bson-cmp.h Created: 08/Aug/22  Updated: 28/Oct/23  Resolved: 09/Aug/22

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.22.0, 1.22.1
Fix Version/s: 1.23.0, 1.22.2

Type: Bug Priority: Unknown
Reporter: Jeremy Mikola Assignee: Ezra Chung
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to PHPC-2157 Upgrade libmongoc to 1.22.2 Closed

 Description   

Summary

User in mongodb/mongo-php-driver#1342 reported an issue compiling PHPC with bundled libmongoc on Alpine Linux for a Docker configuration.

Compile error is as follows:

#19 245.1 In file included from /php-8.1.9/ext/mongodb/src/libmongoc/src/libbson/src/bson/bson-compat.h:35,
#19 245.1 from /php-8.1.9/ext/mongodb/src/libmongoc/src/libbson/src/bson/bson.h:23,
#19 245.1 from /php-8.1.9/ext/mongodb/src/phongo_structs.h:20,
#19 245.1 from /php-8.1.9/ext/mongodb/src/phongo_classes.h:20,
#19 245.1 from /php-8.1.9/ext/mongodb/php_phongo.h:35,
#19 245.1 from main/internal_functions_cli.c:50:
#19 245.1 /php-8.1.9/ext/mongodb/src/libmongoc/src/libbson/src/bson/bson-cmp.h:123:42: error: redefinition of 'bson_in_range_long_signed'
#19 245.1 123 | static BSON_INLINE bool BSON_CONCAT3 (bson_in_range_, Type, _signed) ( \
#19 245.1 | ^~~~~~~~~~~~~~
#19 245.1 /php-8.1.9/ext/mongodb/src/libmongoc/src/libbson/src/bson/bson-macros.h:326:34: note: in definition of macro 'BSON_CONCAT_IMPL'
#19 245.1 326 | #define BSON_CONCAT_IMPL(a, ...) a##__VA_ARGS__
#19 245.1 | ^
#19 245.1 /php-8.1.9/ext/mongodb/src/libmongoc/src/libbson/src/bson/bson-macros.h:328:31: note: in expansion of macro 'BSON_CONCAT'
#19 245.1 328 | #define BSON_CONCAT3(a, b, c) BSON_CONCAT (a, BSON_CONCAT (b, c))
#19 245.1 | ^~~~~~~~~~~
#19 245.1 /php-8.1.9/ext/mongodb/src/libmongoc/src/libbson/src/bson/bson-cmp.h:123:28: note: in expansion of macro 'BSON_CONCAT3'
#19 245.1 123 | static BSON_INLINE bool BSON_CONCAT3 (bson_in_range_, Type, _signed) ( \
#19 245.1 | ^~~~~~~~~~~~
#19 245.1 /php-8.1.9/ext/mongodb/src/libmongoc/src/libbson/src/bson/bson-cmp.h:174:1: note: in expansion of macro 'BSON_IN_RANGE_SET_SIGNED'
#19 245.1 174 | BSON_IN_RANGE_SET_SIGNED (ssize_t, SSIZE_MIN, SSIZE_MAX)
#19 245.1 | ^~~~~~~~~~~~~~~~~~~~~~~~
#19 245.1 /php-8.1.9/ext/mongodb/src/libmongoc/src/libbson/src/bson/bson-cmp.h:123:42: note: previous definition of 'bson_in_range_long_signed' with type '_Bool(int64_t)' {aka '_Bool(long int)'}

This dates back to mongodb/mongo-c-driver#960, which had no CDRIVER ticket that I could find.

The error is reported on line 174 of bson-cmp.h, and may be caused by a some conflict between ssize_t and int64_t.

Environment

Compiling libmongoc 1.22.0 on Alpine Linux. The version of Alpine is unclear, but I can dig up more details if needed.

How to Reproduce

The linked repository does not have clear instructions for loading the Docker configuration; however, this may be reproducible by compiling libbson on Alpine Linux directly.



 Comments   
Comment by Ezra Chung [ 09/Aug/22 ]

PR: https://github.com/mongodb/mongo-c-driver/pull/1091
Commit (master): https://github.com/mongodb/mongo-c-driver/commit/b0be82bbfa34b940cdd11bd0ab3f8b478196f417
Commit (r1.22): https://github.com/mongodb/mongo-c-driver/commit/c85d1c191853b890c50789520897c5d1c49af231

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