I am generating C-code to run on embedding systems and the code that I want to generate contains calls to functions with a large number of parameters. The number of these parameters is always known when I generate the functions and they always consist of a number of input and output arrays.
In my current version of the code, the C-code that I generate contains functions of the form:
void f(const double* x0, const double* x1, const double* x2, double* r0, double* r1);
In this case, I have 3 inputs arrays and 2 output arrays. In general, however, the number of input and output arrays can be very large, as in hundreds or thousands. Note that the code is not intended to be read by humans.
Now, I've learnt that the C standard only guarantees support for up to 127 function parameters. Moreover, I also want my generated code to conform to strict coding standards for embedded systems and I have seen that the Jet Propulsion Laboratory's coding standard for C-code only allows up to 6 parameters.
So, how can I rewrite the code above with at most 6 function parameters in the most efficient way? Note that I am only interested in execution speed, not code readability.
My first idea is to handle the function above as follows:
void f(const double* x[], double* r[]);
and then call this code as follows (thread safety is not an issue):
static const double* x[] = {x0, x1, x2};
static double* r[] = {r0, r1};
f(x,r);
Is this a good idea? Are there other, more efficient alternatives?