Drake exposes its version to downstream C++ as preprocessor macros, so that code can adapt to the Drake version at compile time, e.g., to handle API changes across releases.
Python users should instead obtain the version at runtime via importlib.metadata.version("drake").
Macros | |
| #define | DRAKE_VERSION_STRING |
| Drake's full version string. | |
| #define | DRAKE_VERSION_AT_LEAST(major, minor, patch, yyyymmdd, if_unstamped) |
| Evaluates to true iff this build of Drake is at least as new as the given release. | |
| #define | DRAKE_VERSION_IS_UNSTAMPED |
| Evaluates to true iff this build of Drake is unstamped, i.e., it carries no version information (DRAKE_VERSION_STRING is "unknown"), as happens for a plain bazel build from a source checkout. | |
| #define DRAKE_VERSION_AT_LEAST | ( | major, | |
| minor, | |||
| patch, | |||
| yyyymmdd, | |||
| if_unstamped ) |
Evaluates to true iff this build of Drake is at least as new as the given release.
It handles stable releases, nightly/snapshot builds, and unstamped builds:
The yyyymmdd argument is the nightly date that corresponds to the stable (major, minor, patch) release. The optional fifth argument, if_unstamped, is the value to use for an unstamped build (e.g., a plain bazel build); it defaults to false. Prefer true only when you control the build and know it is recent, because an unstamped build could otherwise be arbitrarily old; see also DRAKE_VERSION_IS_UNSTAMPED.
Intended for use in preprocessor conditionals:
| #define DRAKE_VERSION_IS_UNSTAMPED |
Evaluates to true iff this build of Drake is unstamped, i.e., it carries no version information (DRAKE_VERSION_STRING is "unknown"), as happens for a plain bazel build from a source checkout.
Stable releases and nightly or snapshot builds are always stamped, so this is false in those cases.
Because DRAKE_VERSION_AT_LEAST by default evaluates to false for an unstamped build, downstream code can use this macro to detect an unstamped build and handle it explicitly, e.g., to warn or take a dedicated code path:
| #define DRAKE_VERSION_STRING |
Drake's full version string.
For a versioned release this looks like "1.51.1"; for a nightly or snapshot build like "0.0.20260721.143022+gitabc"; for an unstamped build it is "unknown".