
Paul Mensonides <pmenso57 <at> comcast.net> writes:
On Mon, 14 Nov 2011 19:13:17 +0000, Jens Gustedt wrote: (Excluding the pathological case of a unbalanced parenthesis.)
Paul thanks a lot for your detailed explanation. yes, I am not interested in that case. I don't expect a compiler/preprocessor to don anything sensible when someone tries to pass in expressions that lead to unbalanced parenthesis.
You can make it work with input terminating in a function-like macro at the cost of making it not work for other things.
Still (even with your explanations below) I don't capture cases that my macro wouldn't handle.
The other way is by intentionally putting a (variadic) function-like macro name in front of the argument and a () after the argument which may expand against the argument and may expand against the trailing () that you added. However, if the argument ends in a function-like macro name, you have no idea what that macro is, what its arity is, what it expands to, etc..
my macro does a case analysis of four different scenarios and decides upon that. And I re-read the standard (C99) several times and implemented my own preprocessor to see if I captured all corner cases. Maybe I overlooked a case, then it should be possible to add that or at least it should be possible to document that behavior. So I would be very curious if you could point me on a concrete example of such a case.
The bottom line is that there is no general way to interact with the argument that doesn't cause compiler errors with some input.
Please, be more concrete and show me such an input. Jens