BSON_VERSION(3)

BSON_VERSION(3) β€” Versioning Macros and Functions ✨

okay bestie, welcome to the libbson manual page for BSON_VERSION(3) β€” it's literally all about versioning macros and functions, and it's giving β€œlet me check what version I’m compiling against” main character energy. πŸŽ€


🌈 MACROS 🌈

so the following preprocessor macros are here to do various checks based on the version of the library you’re compiling against. lowkey iconic when you only want to enable a feature on a certain version of the library β€” no cap, that’s exactly the use case. πŸ’…

✨ SYNOPSIS ✨

here’s the whole synopsis, verbatim bestie:

#define BSON_CHECK_VERSION(major, minor, micro)

#define BSON_MAJOR_VERSION (1)
#define BSON_MINOR_VERSION (4)
#define BSON_MICRO_VERSION (1)
#define BSON_VERSION_S "1.4.1"

#define BSON_VERSION_HEX                                  \
   (BSON_MAJOR_VERSION << 24 | BSON_MINOR_VERSION << 16 | \
    BSON_MICRO_VERSION << 8)

and if you wanna only compile a block on Libbson 1.1.0 and newer, you do it like this:

#if BSON_CHECK_VERSION(1, 1, 0)
static void
do_something (void)
{
}
#endif

that’s the vibe: BSON_CHECK_VERSION(major, minor, micro) is the check, and the numeric macros are BSON_MAJOR_VERSION (1), BSON_MINOR_VERSION (4), BSON_MICRO_VERSION (1), plus BSON_VERSION_S ("1.4.1") and BSON_VERSION_HEX doing its little shift-and-or thing. πŸ¦‹

πŸ’– AUTHOR πŸ’–

MongoDB, Inc β€” periodt. πŸ‘‘

2009-present, MongoDB, Inc. β€” protecting the legacy, fr fr. 🌸


mwah πŸ’‹ this cute lil page was brought to you by libbson version 2.5.6, dated Oct 09, 2026, and the BSON_VERSION(3) manual page itself. xoxo πŸ’œ

πŸ“¦ where this page comes from