James S. Singleton schreef:
I have the following macro:
#define ABC(x) f((x) + 1)
Is it possible to get the preprocessor to replace lines like
x = g(y) + ABC(z/3) ;
with
x = g(y) + f((z/3) + 1) ;
but leave lines like
x = h->ABC(w) ;
alone?
Are you sure your problem is with the preprocessor? I do not know you
application, of course, but when you need this kind of "exceptions", it
makes me think you are suffering from a design-flaw.
It's much better to adress that than introduce some of the kludges
suggested elsewhere in this thread, which will surely end up in
unmaitainable code.
1. Why do you need such an exception?
2. Is employing the same macro in both cases neccesary? If so, why?
3. Can't it be solved differently? You (almost *) ) _always_ have
multiple alternatives to code an algorithm. Choose one that suits you
_and_ the language.
*) I can't think of an example in which there is only one way, but that
does not say there isn't one.