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

Undeclared DNS constants and symbols when building with POSIX 2008

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.21.0
    • Affects Version/s: None
    • Component/s: libmongoc
    • None

      8d1af19 for CDRIVER-4227 introduced -D_XOPEN_SOURCE=700, which specifies POSIX 2008. When adding that to PHPC's CFLAGS, I now see errors that several DNS constants and symbols are no longer defined. The Conforming To section of h_errno(3) states:

      POSIX.1-2008 removes the specifications of gethostbyname(), gethostbyaddr(), and _h_errno_, recommending the use of getaddrinfo(3) and getnameinfo(3) instead.

      Seems relevant, but I'm not sure why libmongoc didn't require additional changes (mongodb/mongo-c-driver#910) when instituting that change. Build errors follow:
       

      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c: In function ‘_mongoc_hstrerror’:
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c:306:9: error: ‘HOST_NOT_FOUND’ undeclared (first use in this function)
        306 |    case HOST_NOT_FOUND:
            |         ^~~~~~~~~~~~~~
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c:306:9: note: each undeclared identifier is reported only once for each function it appears in
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c:308:9: error: ‘NO_ADDRESS’ undeclared (first use in this function)
        308 |    case NO_ADDRESS:
            |         ^~~~~~~~~~
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c:310:9: error: ‘NO_RECOVERY’ undeclared (first use in this function)
        310 |    case NO_RECOVERY:
            |         ^~~~~~~~~~~
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c:312:9: error: ‘TRY_AGAIN’ undeclared (first use in this function); did you mean ‘EAI_AGAIN’?
        312 |    case TRY_AGAIN:
            |         ^~~~~~~~~
            |         EAI_AGAIN
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c: In function ‘srv_callback’:
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c:349:37: error: ‘h_errno’ undeclared (first use in this function); did you mean ‘errno’?
        349 |                  _mongoc_hstrerror (h_errno));
            |                                     ^~~~~~~
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c:99:23: note: in definition of macro ‘DNS_ERROR’
         99 |                       __VA_ARGS__);                        \
            |                       ^~~~~~~~~~~
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c: In function ‘_mongoc_get_rr_search’:
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c:495:40: error: ‘h_errno’ undeclared (first use in this function); did you mean ‘errno’?
        495 |                     _mongoc_hstrerror (h_errno));
            |                                        ^~~~~~~
      phpc/src/libmongoc/src/libmongoc/src/mongoc/mongoc-client.c:99:23: note: in definition of macro ‘DNS_ERROR’
         99 |                       __VA_ARGS__);                        \
            |                       ^~~~~~~~~~~
      

            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: