Skip to content

CDRIVER-5629 do not use bool in BSON DSL #1667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 10, 2024

Conversation

kevinAlbs
Copy link
Collaborator

Summary

Replace bool in BSON DSL with boolean.

Evergreen patch: https://spruce.mongodb.com/version/668c26d644a2bb0007db5a0f

Background & Motivation

Intended to avoid possible build errors when bool is defined as a macro. This forum post suggests the user's build environment defines bool (or _Bool) as int, resulting in a build error due to BSON DSL macros evaluating to an undeclared identifier:

mongoc-uri.c:1635:4: error: use of undeclared identifier '_bsonDSL_Type_int'
 1635 |    bsonParse (uri->options,
      |    ^

To reproduce the reported issue, a stdbool.h was added locally to define bool as int:

#ifndef __STDBOOL_CUSTOM_H
#define __STDBOOL_CUSTOM_H

#define bool int
#define true 1
#define false 0
#define __bool_true_false_are_defined 1

#endif /* __STDBOOL_CUSTOM_H */

In the process of testing, other misuse of bool variables in tests were discovered and addressed as drive-by fixes.

kevinAlbs added 5 commits July 8, 2024 13:39
This is a drive-by fix. Discovered locally when testing `bool` defined as `int`.
This is a drive-by fix. Discovered locally when testing `bool` defined as `int`.
To address a reported compile issue: https://www.mongodb.com/community/forums/t/error-when-build-mongo-c-driver-with-visual-studio-2019/287062/2

The report suggests `bool` or `_Bool` was `#define`ed to `int`, causing the DSL to evaluate to undefined symbols (e.g. `_bsonDS
L_Type_int`, instead of `_bsonDSL_Type_bool`).
@kevinAlbs kevinAlbs changed the title do not use bool in BSON DSL CDRIVER-5629 do not use bool in BSON DSL Jul 8, 2024
@kevinAlbs kevinAlbs requested a review from vector-of-bool July 8, 2024 19:20
Copy link
Contributor

@vector-of-bool vector-of-bool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This is a good fix.

@kevinAlbs kevinAlbs merged commit f3bc6e3 into mongodb:master Jul 10, 2024
44 of 46 checks passed
kevinAlbs added a commit that referenced this pull request Jul 10, 2024
* fix usage of `drop_target` bool in test

* use correct return type in test

* update BSON DSL to use `boolean`, rather than `bool`

To address a reported compile issue: https://www.mongodb.com/community/forums/t/error-when-build-mongo-c-driver-with-visual-studio-2019/287062/2

The report suggests `bool` or `_Bool` was `#define`ed to `int`, causing the DSL to evaluate to undefined symbols (e.g. `_bsonDSL_Type_int`, instead of `_bsonDSL_Type_bool`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants