Add a more convenient method for compile/run-time version checks.

This commit is contained in:
Jef Driesen 2010-04-29 09:21:05 +00:00
parent fed4e562ee
commit 2cd09fd525
3 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,5 @@
dc_version
dc_version_check
dc_buffer_new
dc_buffer_free

View File

@ -33,3 +33,9 @@ dc_version (dc_version_t *version)
return DC_VERSION;
}
int
dc_version_check (unsigned int major, unsigned int minor, unsigned int micro)
{
return DC_VERSION_CHECK (major,minor,micro);
}

View File

@ -32,6 +32,12 @@ extern "C" {
#define DC_VERSION_MICRO @DC_VERSION_MICRO@
#define DC_VERSION_EXTRA "@DC_VERSION_EXTRA@"
#define DC_VERSION_CHECK(major,minor,micro) \
(DC_VERSION_MAJOR > (major) || \
(DC_VERSION_MAJOR == (major) && DC_VERSION_MINOR > (minor)) || \
(DC_VERSION_MAJOR == (major) && DC_VERSION_MINOR == (minor) && \
DC_VERSION_MICRO >= (micro)))
typedef struct dc_version_t {
unsigned int major;
unsigned int minor;
@ -42,6 +48,9 @@ typedef struct dc_version_t {
const char *
dc_version (dc_version_t *version);
int
dc_version_check (unsigned int major, unsigned int minor, unsigned int micro);
#ifdef __cplusplus
}
#endif /* __cplusplus */