Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

version.h

86 lines2.9 KB

1/**
2 * @file version.h
3 *
4 * Version - the version of the libghostty-vt headers.
5 */
6​
7#ifndef GHOSTTY_VT_VERSION_H
8#define GHOSTTY_VT_VERSION_H
9​
10/** @addtogroup version
11 *
12 * libghostty-vt has two versions you may care about: the version of the headers
13 * your program compiled against, and the version of the library it loads when
14 * it runs.
15 *
16 * The macros here describe the headers. ghostty_version() and
17 * ghostty_build_info() report the library. These are usually the same. They can
18 * differ when a program compiled against one release runs on a system with
19 * another release installed. A library with the same major version works
20 * as long as it is at least as new as the headers.
21 *
22 * ## Example
23 *
24 * @snippet c-vt-build-info/src/main.c version-check
25 *
26 * Full program: @ref c-vt-build-info/src/main.c
27 *
28 * See @ref stability for what each release may break, and
29 * @ref stability-check for how to check the library when your program starts.
30 *
31 * @{
32 */
33​
34/** The major version of the libghostty-vt headers. */
35#define GHOSTTY_VT_VERSION_MAJOR 1
36​
37/** The minor version of the libghostty-vt headers. */
38#define GHOSTTY_VT_VERSION_MINOR 0
39​
40/** The patch version of the libghostty-vt headers. */
41#define GHOSTTY_VT_VERSION_PATCH 2
42​
43/**
44 * The version of the libghostty-vt headers as a string, such as "1.0.0".
45 *
46 * This is always three numbers separated by dots. It never has a
47 * pre-release or build suffix such as "-dev". Use ghostty_version() for
48 * the full version of the library.
49 *
50 * Builds made between releases use the number of the release they are
51 * working towards. For example, a development build before 1.1.0 sets
52 * GHOSTTY_VT_VERSION to "1.1.0", while ghostty_version() returns the
53 * full version, such as "1.1.0-dev+abc1234".
54 *
55 * The CMake package and the pkg-config file installed with
56 * libghostty-vt carry the same version, and are the easiest way to check
57 * it from a build system. This header contains only macros and includes
58 * no other files, so a build system can also read it directly.
59 */
60#define GHOSTTY_VT_VERSION "1.0.2"
61​
62/**
63 * True if the headers are version maj.min.pat or newer.
64 *
65 * This works in `#if` directives as well as in regular code:
66 *
67 * @code
68 * #if GHOSTTY_VT_VERSION_AT_LEAST(1, 1, 0)
69 * // Code that uses functions added in 1.1.0.
70 * #endif
71 * @endcode
72 *
73 * @param maj The major version to compare against
74 * @param min The minor version to compare against
75 * @param pat The patch version to compare against
76 */
77#define GHOSTTY_VT_VERSION_AT_LEAST(maj, min, pat) \
78 (GHOSTTY_VT_VERSION_MAJOR > (maj) || \
79 (GHOSTTY_VT_VERSION_MAJOR == (maj) && \
80 (GHOSTTY_VT_VERSION_MINOR > (min) || \
81 (GHOSTTY_VT_VERSION_MINOR == (min) && \
82 GHOSTTY_VT_VERSION_PATCH >= (pat)))))
83​
84/** @} */
85​
86#endif /* GHOSTTY_VT_VERSION_H */