barrym95838 wrote:
BigDumbDinosaur wrote:
As for the efficiency argument, it would depend on how one defines "less efficient."
I think he means that the resultant machine code may have redundant instructions that would be easier to see and optimize out if the macros weren't obscuring the details.
Could be. The decision to use macros instead of lines of code has to be made with the understanding that anything that adds higher-level elements to the source code is bound to bulk up things. Some of the macros I use do just that, whereas others, such as the aforementioned
sprint call, produce the same amount of code as typing the individual instruction statements.
Quote:
On further reflection, I'm starting to think of macros more as a matter of taste, kind of like manual vs. automatic transmissions in our vehicles. I can easily see the pros and cons of each.
I am more likely to use macros in forming complicated function calls in which a stack frame must be built prior to calling the subroutine. In such a case, use of a macro reduces the likelihood of introducing an error, as the macro can be written to alert the programmer if a parameter is missing, is out of order, etc.