maedoc / libtvb

TVB C library
6 stars 8 forks source link

Simplify function signatures #131

Open maedoc opened 8 years ago

maedoc commented 8 years ago

Some function signatures are too complex, and it's far too easy to forget order. If there's no point in creating an interface to support the function call, it could be as simple as converting

void foo(int a, int b, int c, int d);

to

struct foo_args { int a, b, c, d; };
void foo(struct foo_args *args);

where in C99 calling can be concise almost like keyword arguments,

foo((struct foo_args) {.d=43, .c=2, .b=2, .a=2});

and in older dialects more verbose

struct foo_args args;
args.a = 2;
args.b = 2;
args.c = 2;
args.d = 42;
foo(&args);

but we already assume C99 per variadic macros, so this isn't too much an issue.

paramhanji commented 8 years ago

This involves scanning the header files and changing all signatures. And then looking through the files and changing corresponding headers there too right?

maedoc commented 8 years ago

Yes, but I don't actually want to do this yet. I'm still refactoring the API a little bit.