Skip to content

include: add preprocessor macros for default params

Niklas Haas requested to merge params_define into master

This quasi-deprecates the extern const default_params structs, both since overriding their values is annoying in C (can't use designated initializers), and also because they require data exports, which are not universally supported.

The new paradigm is to write code like this:

pl_whatever(..., pl_whatever_params(
    .foo = a,
    .bar = b,
));

Instead of this:

pl_whatever(..., &(struct pl_whatever_params) {
    .foo = a,
    .bar = b,
})

This is not only shorter and prettier but also implicitly inherits the default values of these params structs, which previously required abominations such as:

pl_whatever_params whatever_params = pl_whatever_default_params;
whatever_params.foo = a;
whatever_params.bar = b;
pl_whatever(..., &whatever_params);

Of course, the above only works in C, so C++ users will still have to write the ugly variants. That's also why I'm not deprecating the extern const structs (or turning them into static const declarations).

This commit only updates the headers, to keep it manageable. The next commit will comb through the source code and replace all internal params structs.

Edited by Niklas Haas

Merge request reports