M
Max TenEyck Woodbury
I have a static array that requires quite complicated initialization.
With C89 I constructed a set of macros that greatly simplified that
process but required the user to count the number of arguments. With
the advent of C99, I can get around that problem. However I wish to
hide even more of the implementation details being yet another macro.
The macro would have a form something like SUPER_TABLE( name, (...)...)
where the (...) arguments would be processed by the macro I described
above. The problem is the mechanism behind SUPER_TABLE.
The macro would do what was needed with 'name', check to see if there
is more than one additional argument in the argument list, (how this
can be done was discussed quite some time ago in this news group) and
invoke SUPER_TABLE0 if here was only one, or SUPER_TABLE1 if there
as more than one. SUPER_TABLE0 is what I already have. SUPER_TABLE1
would split off one argument set and pass it to SUPER_TABLE0, then
pass the rest of the arguments to another incarnation of itself.
The termination of the initialization would be in SUPER_TABLE.
The problem is how to get around the preprocessor's recursion
prevention. Recursion is safe in this case because it is limited
to one level per argument. However the number of arguments could
be arbitrarily large so counting the arguments is not a solution.
Could somebody tell me how to do this?
With C89 I constructed a set of macros that greatly simplified that
process but required the user to count the number of arguments. With
the advent of C99, I can get around that problem. However I wish to
hide even more of the implementation details being yet another macro.
The macro would have a form something like SUPER_TABLE( name, (...)...)
where the (...) arguments would be processed by the macro I described
above. The problem is the mechanism behind SUPER_TABLE.
The macro would do what was needed with 'name', check to see if there
is more than one additional argument in the argument list, (how this
can be done was discussed quite some time ago in this news group) and
invoke SUPER_TABLE0 if here was only one, or SUPER_TABLE1 if there
as more than one. SUPER_TABLE0 is what I already have. SUPER_TABLE1
would split off one argument set and pass it to SUPER_TABLE0, then
pass the rest of the arguments to another incarnation of itself.
The termination of the initialization would be in SUPER_TABLE.
The problem is how to get around the preprocessor's recursion
prevention. Recursion is safe in this case because it is limited
to one level per argument. However the number of arguments could
be arbitrarily large so counting the arguments is not a solution.
Could somebody tell me how to do this?