#33 Version information

open
nobody
mpg123 (18)
5
2013-09-16
2012-07-31
Joachim Puhr
No

A function to query the version information of the library (to display in a messagebox) would be great.

Discussion

  • Thomas Orgis
    Thomas Orgis
    2012-07-31

    You have a point there. What would make most sense, a string, a set of numbers (major, minor, bugfix) plus extra identifier (alpha, beta, ...)?

    We wouldn't even need a function ... a simple external const variable would do it, too. Otherwise, one could extend mpg123_feature to return version numbers ...

    major = mpg123_feature(MPG123_FEATURE_MAJOR);
    minor = mpg123_feature(MPG123_FEATURE_MINOR);
    bugfix = mpg123_feature(MPG123_FEATURE_BUGFIX);

    though, that still would be overkill compared to

    extern const int mpg123_major;
    extern const int mpg123_minor;
    extern const int mpg123_bugfix;
    extern const char* mpg123_version_string;

    (mpg123_version is already the name of an enum)

     
  • Joachim Puhr
    Joachim Puhr
    2012-07-31

    Hello, as a proposal, here is the version code from the lame project (lame.h file):

    /*
    * OPTIONAL:
    * get the version number, in a string. of the form:
    * "3.63 (beta)" or just "3.63".
    */
    const char* CDECL get_lame_version ( void );
    const char* CDECL get_lame_short_version ( void );
    const char* CDECL get_lame_very_short_version ( void );
    const char* CDECL get_psy_version ( void );
    const char* CDECL get_lame_url ( void );
    const char* CDECL get_lame_os_bitness ( void );

    /*
    * OPTIONAL:
    * get the version numbers in numerical form.
    */
    typedef struct {
    /* generic LAME version */
    int major;
    int minor;
    int alpha; /* 0 if not an alpha version */
    int beta; /* 0 if not a beta version */

    /* version of the psy model */
    int psy_major;
    int psy_minor;
    int psy_alpha; /* 0 if not an alpha version */
    int psy_beta; /* 0 if not a beta version */

    /* compile time features */
    const char *features; /* Don't make assumptions about the contents! */
    } lame_version_t;
    void CDECL get_lame_version_numerical(lame_version_t *);

    -----------------------------------------------------------------------------------------

    Alternatively, the Boost library only has version macros (from version.hpp):

    // Caution, this is the only boost header that is guarenteed
    // to change with every boost release, including this header
    // will cause a recompile every time a new boost version is
    // released.
    //
    // BOOST_VERSION % 100 is the patch level
    // BOOST_VERSION / 100 % 1000 is the minor version
    // BOOST_VERSION / 100000 is the major version

    #define BOOST_VERSION 105000

    //
    // BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
    // but as a *string* in the form "x_y[_z]" where x is the major version
    // number, y is the minor version number, and z is the patch level if not 0.
    // This is used by <config/auto_link.hpp> to select which library version to link to.

    #define BOOST_LIB_VERSION "1_50"

    -----------------------------------------------------------------------------------

    The same is in the Qwt project:

    // QWT_VERSION is (major << 16) + (minor << 8) + patch.
    #define QWT_VERSION 0x060001
    #define QWT_VERSION_STR "6.0.1"

     
  • Thomas Orgis
    Thomas Orgis
    2013-09-16

    Damn, since sf.net reworked itself, I'm rather disconnected from the stuff that happens here .. need to get the ticket system to keep my mailbox informed.

    Is the MPG123_API_VERSION of some use? I don't really fancy adding a host of functions for that. I'd opt for the library adding string constant with the full version ("1.15.4-experimental-prealpha"). One might also add a numerical constant to mirror MPG123_API_VERSION at build time. Feature query is already there, mpg123_feature().

    Would that be fine? I might just add it for 1.16.0 .