[PATCH] version.h: Add version check macro

Kristian Høgsberg hoegsberg at gmail.com
Sun Sep 29 14:56:14 PDT 2013


On Sun, Sep 29, 2013 at 11:57:12AM +0200, Pier Luigi wrote:
> 2013/9/24 Bill Spitzak <spitzak at gmail.com>:
> >
> >
> > Kristian Høgsberg wrote:
> >>
> >> On Tue, Sep 24, 2013 at 12:54 AM, Marc Chalain <marc.chalain at gmail.com>
> >> wrote:
> >>
> >>>
> >>> But the WESTON_VERSION_AT_LEAST macro is wrong. You can check only the
> >>> minor
> >>> and not the rest of the version.
> >>>
> >>
> >>
> >> No, we don't guarantee plugin API stability between x.y releases, only
> >> micro releases 1.2.x maintain that interface.  Something developed for
> >> 1.1.2 isn't guaranteed to work on 1.2.1, but anything written against
> >> 1.2.1 will work on 1.2.2 and later 1.2.x releases.
> >
> > That does not seem right. This will require anybody writing a plugin using a
> > feature added in 1.2.3 and never removed to do this:
> >
> > #if WESTON_VERSION_AT_LEAST(1,2,3) || WESTON_VERSION_AT_LEAST(1,3,0) ||
> > WESTON_VERSION_AT_LEAST(1,4,0) || WESTON_VERSION_AT_LEAST(1,5,0) || ....etc
> >
> > If this macro was written the way I think most people expect, then in the
> > case something vanishes in 1.3.0 they can write:
> >
> > #if WESTON_VERSION_AT_LEAST(1,3,0)
> >  ... it is missing (but there may be a better replacement) ...
> > #elif WESTON_VERSION_AT_LEAST(1,2,3)
> >  ... use the api ...
> > #else
> >  ... it is missing ...
> > #endif
> >
> 
> I think what Kristian meant is that no interface changes are allowed
> in micro releases so big changes involving interfaces goes only on
> minor release.
> 
> For example, if views are going in for 1.3 (haven't followed the list
> much recently, but let's just assume it will), plugins would write a
> check like this:
> 
> #if WESTON_VERSION_AT_LEAST(1,3,0)
>     ... view stuff
> #else
>     ... old way of dealing with this stuff
> #endif
> 
> And that's fine until Weston 2.x comes out, so the check will look like:
> 
> #if WESTON_VERSION_MAJOR >= 1 && WESTON_VERSION_AT_LEAST(1,3,0)
>     ... view stuff
> #else
>     ... old way of dealing with this stuff
> #endif
> 
> Perhaps we should keep the original version check macro the way I did it:
> 
> #define WESTON_VERSION_CHECK(major, minor, micro) ((major << 16) |
> (minor << 8) | (micro))
> 
> So the check will look like much clean:
> 
> #if WESTON_VERSION_NUMBER >= WESTON_VERSION_CHECK(1, 3, 0)
>    ... view stuff
> #else
>     ... old way
> #endif
> 
> This gives plugin writers much more freedom and they can actually
> check for micro versions too, which is useful if they want to make
> sure Weston has certain features (that might not involve interface
> changes).

No, we don't guarantee plugin API compatiblity from 1.2 to 1.3.  We
may remove functions, structure fields, or change how existing
functions work between 1.x versions.  There is no guarantee your
plugin will work or even compile with 1.3 even if it works with 1.2,
but it will work with every later 1.2.x release.  That's why I made
the change to the version check macro.

We're essentially treating the minor version number as a major version
number for the plugin API.  This is probably where the confusion comes
from.

Kristian


More information about the wayland-devel mailing list