[CDRIVER-2563] Check that all public symbols are marked extern "C" Created: 21/Mar/18  Updated: 28/Oct/23  Resolved: 23/Mar/18

Status: Closed
Project: C Driver
Component/s: tests
Affects Version/s: None
Fix Version/s: 1.10.0

Type: New Feature Priority: Minor - P4
Reporter: A. Jesse Jiryu Davis Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-2562 Change streams functions not marked e... Closed
Backwards Compatibility: Fully Compatible

 Description   

Prevent bugs like CDRIVER-2562. Write a script to run in Evergreen that reads all header files without "-private.h" in their names in src/mongoc and src/libbson/src/bson, and asserts they all contain BSON_BEGIN_DECLS and BSON_END_DECLS.



 Comments   
Comment by Kevin Albertson [ 23/Mar/18 ]

Forgot to add the ticket number to the commit message:
https://github.com/mongodb/mongo-c-driver/commit/8d4c916c2a2f80a682af20b2d1169624681bfd48

Comment by Kevin Albertson [ 21/Mar/18 ]

Checking this locally it doesn't look like there are any other files missing this. Here's a cleaned up version of the bash script I used, which might be able to be modified for the evergreen task:

# run this script from the root of the mongo-c-driver repository.
# files we expect not to have these decls
exclude="\.\/src\/mongoc\/mongoc-macros.h|.\/src\/mongoc\/mongoc.h"
pattern="\.\/src\/mongoc\/mongoc.*[^private]\.h$"
 
# get all non-private headers
find -E ./src/mongoc -regex $pattern -not -regex $exclude | sort  > /tmp/all.txt
 
# get all non-private headers with BSON_START_DECL
find -E ./src/mongoc -regex $pattern -not -regex $exclude | xargs grep -l "BSON_BEGIN_DECLS" | sort > /tmp/not_missing.txt
 
# check if there's any diff
diff -y /tmp/all.txt /tmp/not_missing.txt
 
# use return status of diff
exit $?

Generated at Wed Feb 07 21:15:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.