Using macro as an abstraction layer

abstractioncmacros

I am having a discussion with a colleague about using macro as a thin (extremely) layer of abstraction vs using a function wrapper. The example that I used is

Macro way.

#define StartOSTimer(period)  (microTimerStart(period))

Function wrapper method

void StartOSTimer(period)
{
    microTimerStart(period);
}

Personally, I liked the second method as it allows for future modification, the #include dependencies are also abstracted as well.

Best Answer

Macros are hideous abominations that should be avoided in every situation you can possibly get away with. You'd have to have a fairly extreme justification to use one.