Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-2195

Implicit declaration warnings caused by libmongocrypt-compat header

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.16.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I observed the following build warnings when compiling with gcc-11.3.0 (included with Ubuntu 22.04). I was previously using gcc-9.3.0 on Ubuntu 20.04, which might explain why I never encountered this before.

      /phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-crypt.c: In function ‘_create_explicit_state_machine’:
      /phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-crypt.c:1574:12: warning: implicit declaration of function ‘mongocrypt_ctx_setopt_algorithm_range’; did you mean ‘mongocrypt_ctx_setopt_algorithm’? [-Wimplicit-function-declaration]
       1574 |       if (!mongocrypt_ctx_setopt_algorithm_range (state_machine->ctx,
            |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            |            mongocrypt_ctx_setopt_algorithm
      /phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-crypt.c: In function ‘_mongoc_crypt_explicit_encrypt_expression’:
      /phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-crypt.c:1781:9: warning: implicit declaration of function ‘mongocrypt_ctx_explicit_encrypt_expression_init’; did you mean ‘mongocrypt_ctx_explicit_encrypt_init’? [-Wimplicit-function-declaration]
       1781 |    if (!mongocrypt_ctx_explicit_encrypt_expression_init (state_machine->ctx,
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            |         mongocrypt_ctx_explicit_encrypt_init
      

      Researching this lead me to src/libmongocrypt-compat/mongocrypt/mongocrypt.h, which was introduced in 7cea21a for PHPC-1496 and not changed since.

      The file contains:

      #include "../libmongocrypt/src/mongocrypt.h"
      

      The relative path isn't valid on its own and relies on the following in config.m4 (also added in 7cea21a):

      PHP_MONGODB_ADD_INCLUDE([src/libmongocrypt-compat/])
      

      Changing the path to "../../libmongocrypt/src/mongocrypt.h" happens to resolve the two build warnings, but it's not immediately clear to me why that is.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: