[CDRIVER-2271] BSON_STATIC_ASSERT can trigger "error: redefinition of typedef" in clang Created: 10/Sep/17 Updated: 28/Oct/23 Resolved: 12/Jan/18 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libbson |
| Affects Version/s: | None |
| Fix Version/s: | 1.9.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | A. Jesse Jiryu Davis | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
The BSON_ASSERT macro uses typedef tricks to force a compilation error if the static invariant it asserts is false. Unfortunately the symbols it typedefs are named only using the line number on which BSON_ASSERT is used. E.g. if there is a BSON_ASSERT on line 112, then a symbol static_assert_test_112 is involved in checking the invariant. If BSON_ASSERT is used in two files on the same line number in each, a pedantic compiler errors, "error: redefinition of typedef 'static_assert_test_112'". See for example: To solve, make a new macro BSON_STATIC_ASSERT2 that allows a custom string prefix:
|
| Comments |
| Comment by Githook User [ 10/Jan/18 ] |
|
Author: {'email': 'ppisar@redhat.com', 'name': 'Petr Písař', 'username': 'ppisar'}Message: The macro definition was mistakenly changed in 1.9.0 ( Signed-off-by: Petr Písař <ppisar@redhat.com> |
| Comment by Githook User [ 15/Oct/17 ] |
|
Author: {'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis'}Message: |
| Comment by Githook User [ 15/Oct/17 ] |
|
Author: {'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis'}Message: |