What is pField
(besides a fine example of the abomination that is Systems Hungarian)? If, by chance, it s a global variable or a singleton or something that we only need one of, we could do a nifty trick like this:
int FFX(int x)
{
static FIELD *pField = ...; // remove this line if pField is global
return pField->GetValue(x);
}
Change the int
types to whatever types you need it to operate on, or even a template if you need it to support multiple types.
Another alternative, suggested by @epatel, is to use your favorite text editor s find-and-replace and just change all the FFX(x)
lines to pField->GetValue(x)
, thus eliminating the macro invokation in your code. If you want to keep a function invokation, you culd change FFX(x)
to FFX(pField, x)
and change the macro to take two arguments (or change it to a function that takes two arguments). But you might as well just take out the macro at that point.
A third alternative, is not to fix that which is not broken. The macro isn t particularly nice, but you may introduce greater problems by trying to remove it. Macros aren t the spawn of Satan (though this one has at least a few relatives in hell).