From a16c95b33fd215f4616fa2e7a80c81bcc629d945 Mon Sep 17 00:00:00 2001 From: Michael Helmling Date: Sat, 23 Jul 2016 13:08:23 +0200 Subject: [PATCH] Adds a function for dynamic version information retrieval The current way of exposing TagLib's version only through #define's makes it impossible for clients (e.g. language bindings) to reliably determine the TagLib version that is currently in use: using the define's in client code will statically copy the compile-time values into the client's library, but if TagLib is dynamically bound the version (at least minor and patch version) can change after building client code. --- taglib/toolkit/taglib.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h index 2f4c5655..18f6b270 100644 --- a/taglib/toolkit/taglib.h +++ b/taglib/toolkit/taglib.h @@ -46,6 +46,8 @@ * \endcode */ +#include + namespace TagLib { enum ByteOrder @@ -53,6 +55,13 @@ namespace TagLib LittleEndian, BigEndian }; + /*! + * Returns the library's version information as 3-tuple of ints (for major, minor, patch version). + */ + std::tuple version() + { + return std::make_tuple(TAGLIB_MAJOR_VERSION, TAGLIB_MINOR_VERSION, TAGLIB_PATCH_VERSION); + } } /*!