Skip to content

Commit

Permalink
Merge pull request #269 from baconpaul/lt_correct
Browse files Browse the repository at this point in the history
Correct CLAP_VERSION_LT
  • Loading branch information
abique authored Dec 30, 2022
2 parents ddbae27 + 07193d0 commit d6cbd4f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Changes in 1.1.6

* [version.h](include/clap/version.h) `CLAP_VERSION_LT` was backwards (comparing current with arg
vs arg with current). Correct and enhance tests.

# Changes in 1.1.5

* [plugin.h](include/clap/plugin.h): clarify plugin state after init()
Expand Down
8 changes: 4 additions & 4 deletions include/clap/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ typedef struct clap_version {

#define CLAP_VERSION_MAJOR 1
#define CLAP_VERSION_MINOR 1
#define CLAP_VERSION_REVISION 5
#define CLAP_VERSION_REVISION 6

#define CLAP_VERSION_INIT \
{ (uint32_t)CLAP_VERSION_MAJOR, (uint32_t)CLAP_VERSION_MINOR, (uint32_t)CLAP_VERSION_REVISION }

#define CLAP_VERSION_LT(maj,min,rev) (((maj) < CLAP_VERSION_MAJOR) || \
((maj) == CLAP_VERSION_MAJOR && (min) < CLAP_VERSION_MINOR ) || \
((maj) == CLAP_VERSION_MAJOR && (min) == CLAP_VERSION_MINOR && (rev) < CLAP_VERSION_REVISION))
#define CLAP_VERSION_LT(maj,min,rev) ((CLAP_VERSION_MAJOR < (maj)) || \
((maj) == CLAP_VERSION_MAJOR && CLAP_VERSION_MINOR < (min)) || \
((maj) == CLAP_VERSION_MAJOR && (min) == CLAP_VERSION_MINOR && CLAP_VERSION_REVISION < (rev)))
#define CLAP_VERSION_EQ(maj,min,rev) (((maj) == CLAP_VERSION_MAJOR) && ((min) == CLAP_VERSION_MINOR) && ((rev) == CLAP_VERSION_REVISION))
#define CLAP_VERSION_GE(maj,min,rev) (!CLAP_VERSION_LT(maj,min,rev))

Expand Down
20 changes: 20 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@
#error CLAP_VERSION_GE was inroduced in 1.1.5 so we should be later than that version.
#endif

#if !CLAP_VERSION_LT(CLAP_VERSION_MAJOR + 1, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION)
#error CLAP_VERSION_LT is inconsistent (MAJOR)
#endif
#if !CLAP_VERSION_LT(CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR + 1, CLAP_VERSION_REVISION)
#error CLAP_VERSION_LT is inconsistent (MINOR)
#endif
#if !CLAP_VERSION_LT(CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION + 1)
#error CLAP_VERSION_LT is inconsistent (REVISION)
#endif

#if CLAP_VERSION_LT(CLAP_VERSION_MAJOR - 1, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION)
#error CLAP_VERSION_LT is inconsistent (MAJOR)
#endif
#if CLAP_VERSION_LT(CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR - 1, CLAP_VERSION_REVISION)
#error CLAP_VERSION_LT is inconsistent (MINOR)
#endif
#if CLAP_VERSION_LT(CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION - 1)
#error CLAP_VERSION_LT is inconsistent (REVISION)
#endif

static const CLAP_CONSTEXPR clap_version m = CLAP_VERSION;

int main(int, char **) {
Expand Down

0 comments on commit d6cbd4f

Please sign in to comment.