Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4451

Build error redefining bson_in_range_long_signed in bson-cmp.h

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.23.0, 1.22.2
    • Affects Version/s: 1.22.0, 1.22.1
    • Component/s: None
    • None

      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.

            Assignee:
            ezra.chung@mongodb.com Ezra Chung
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: