[CDRIVER-2797] Fix include header checks Created: 20/Aug/18 Updated: 28/Oct/23 Resolved: 01/Oct/18 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libbson, libmongoc |
| Affects Version/s: | None |
| Fix Version/s: | 1.14.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Kevin Albertson | Assignee: | Kevin Albertson |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
We have checks to prevent public headers getting included directly in client code outside of bson.h and mongoc.h:
However, some public headers omit the checks like bson-writer.c and mongoc-change-stream.h. And a lot of them define this check after the ifdef guard. Example:
So client code can do something like:
And it compiles without issue. This is because mongoc.h includes mongoc-apm.h, which defines MONGOC_APM_H. So when the client code includes mongoc-apm.h directly, no error occurs. This check should probably be defined outside of the ifdef guard, which only a few files do (e.g. mongoc-rand.h). |
| Comments |
| Comment by Githook User [ 01/Oct/18 ] |
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@10gen.com', 'username': 'kevinAlbs'}Message: |
| Comment by Kevin Albertson [ 24/Aug/18 ] |
|
bcon.h also omits these guards, and circularly #includes bson.h |