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

Incorrect #include pattern causes an extra file system read that is guaranteed to fail

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.16.0
    • Affects Version/s: 1.15.2
    • Component/s: Build
    • None

      bson.h file located in /usr/include/libbson-1.0/bson/ has about to dozenĀ  #include's like these:

      #include "bson/bson-macros.h"
      #include "bson/bson-config.h"
      #include "bson/bson-atomic.h"
      ...
      

      This means that the C preprocessor will first attempt to open every header in the current directory first, will fail and only then will fall back onto the including project include search path to look for those headers, where it also fails on average for half of the paths on the include search path list. Same happens once more for mongoc/mongoc.h, so the pattern repeats over 40 times.

      Given that bson/bson.h and mongoc/mongoc.h have already been found via the including project's search path once, they should include all of their internal headers directly via double quote search paths, like this:

      #include "bson-macros.h"
      #include "bson-config.h"
      #include "bson-atomic.h"...
      

      This guarantees that each header is directly included without falling back onto the including project's search path.

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            cis74633@bell.net Andre M
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: