cmocka: 📌 Version Information

cmocka 2.0.0 Unit testing library with mock support

Loading...
Searching...
No Matches
Macros
📌 Version Information
📚 The CMocka API

Query cmocka library version at compile time and runtime. More...

## Macros
#define | CMOCKA_VERSION_MAJOR 2
| cmocka major version number.
#define | CMOCKA_VERSION_MINOR 0
| cmocka minor version number.
#define | CMOCKA_VERSION_MICRO 0
| cmocka micro (patch) version number.
#define | CMOCKA_VERSION_INT
| cmocka version as an integer for easy comparison.
#define | CMOCKA_VERSION
| cmocka version as a string (e.g., "1.9.0").

## Detailed Description

Query cmocka library version at compile time and runtime.

These macros provide access to the cmocka library version information, allowing you to check which version of cmocka is being used in your tests.

The version is composed of three components:

- MAJOR: Incremented for incompatible API changes
- MINOR: Incremented for added functionality in a backward-compatible manner
- MICRO: Incremented for backward-compatible bug fixes

## Version Check Example

You can use CMOCKA_VERSION_INT to check if the library meets a minimum version requirement:

#include <cmocka_version.h>
// Check if cmocka version is at least 1.2.0
#if CMOCKA_VERSION_INT >= CM_VERSION_INT(1, 2, 0)
// Use features available in cmocka 1.2.0 or later
#endif

## Version String Example

The CMOCKA_VERSION macro can be used to get the version as a string:

#include <stdio.h>
#include <cmocka_version.h>
int main(void) {
printf("cmocka version: %s\n", CMOCKA_VERSION);
return 0;
}
CMOCKA_VERSION
#define CMOCKA_VERSION
cmocka version as a string (e.g., "1.9.0").
Definition cmocka_version.h:148

## Macro Definition Documentation

## ◆ CMOCKA_VERSION

#define CMOCKA_VERSION

Value:
CM_VERSION(CMOCKA_VERSION_MAJOR, \
CMOCKA_VERSION_MINOR, \
CMOCKA_VERSION_MICRO)
CMOCKA_VERSION_MICRO
#define CMOCKA_VERSION_MICRO
cmocka micro (patch) version number.
Definition cmocka_version.h:105
CMOCKA_VERSION_MAJOR
#define CMOCKA_VERSION_MAJOR
cmocka major version number.
Definition cmocka_version.h:90
CMOCKA_VERSION_MINOR
#define CMOCKA_VERSION_MINOR
cmocka minor version number.
Definition cmocka_version.h:98

cmocka version as a string (e.g., "1.9.0").

This macro provides the complete version number as a string constant.

#include <stdio.h>
#include <cmocka_version.h>
printf("Using cmocka version: %s\n", CMOCKA_VERSION);

See also
  CMOCKA_VERSION_INT
  CMOCKA_VERSION_MAJOR
  CMOCKA_VERSION_MINOR
  CMOCKA_VERSION_MICRO

## ◆ CMOCKA_VERSION_INT

#define CMOCKA_VERSION_INT

Value:
CM_VERSION_INT(CMOCKA_VERSION_MAJOR, \
CMOCKA_VERSION_MINOR, \
CMOCKA_VERSION_MICRO)

cmocka version as an integer for easy comparison.

This macro provides the complete version number as a single integer value, which is useful for compile-time version checks.

The version is encoded as: (major << 16) | (minor << 8) | micro

// Require at least cmocka 1.1.5
#if CMOCKA_VERSION_INT < CM_VERSION_INT(1, 1, 5)
#error "cmocka 1.1.5 or later is required"
#endif

See also
  CM_VERSION_INT()
  CMOCKA_VERSION_MAJOR
  CMOCKA_VERSION_MINOR
  CMOCKA_VERSION_MICRO

## ◆ CMOCKA_VERSION_MAJOR

#define CMOCKA_VERSION_MAJOR 2

cmocka major version number.

This is incremented when incompatible API changes are made.

## ◆ CMOCKA_VERSION_MICRO

#define CMOCKA_VERSION_MICRO 0

cmocka micro (patch) version number.

This is incremented for backward-compatible bug fixes.

## ◆ CMOCKA_VERSION_MINOR

#define CMOCKA_VERSION_MINOR 0

cmocka minor version number.

This is incremented when functionality is added in a backward-compatible manner.