Drake
Drake C++ Documentation
Loading...
Searching...
No Matches
Drake Version

Detailed Description

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.

Macro Definition Documentation

◆ DRAKE_VERSION_AT_LEAST

#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:

  • When evaluated against a stable release build, it is true iff the build version is greater than or equal to (major, minor, patch); the yyyymmdd argument is ignored.
  • When evaluated against a nightly or snapshot build, it is true iff the build date is at least yyyymmdd and yyyymmdd is nonzero.
  • When evaluated against an unstamped build, it is false, unless the optional fifth argument if_unstamped is given, in which case that value is used.

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:

#if DRAKE_VERSION_AT_LEAST(1, 51, 1, 20260311)
// ... use a newer Drake API ...
#endif

◆ DRAKE_VERSION_IS_UNSTAMPED

#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:

#if DRAKE_VERSION_IS_UNSTAMPED
#warning "Drake version is unknown (unstamped build)."
#endif

◆ DRAKE_VERSION_STRING

#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".