Mir

Code review comment for lp:~mir-team/mir/alternative-extension-naming

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> 3) Alan's pseudocode (not quite clear to me how this would look in C code, so
> can't comment)

That comes from thinking about what client code looks like and how to keep it self-consistent.

I was thinking something along the lines of:

void load(void* data, char const* interface, unsigned version);

typedef struct { } foo_v1_extensions;

#define DEFINE_MIR_EXTENSION_FOO_VERSION1(var)\
struct { char const* const interface; unsigned const version; foo_v1_extensions extensions; } \
var = { "foo_v1_extensions_interface", 1, };

int main()
{
    DEFINE_MIR_EXTENSION_FOO_VERSION1(x1);
    load(&x1.extensions, x1.interface, x1.version);
    return 0;
}

« Back to merge proposal