Electrical – What are the limitations of macro in embedded programming?

cembeddedmicrocontroller

What could be the limitations of macros in embedded system programming.
In contrast to c programming.

Best Answer

As it is worded, the question you quote makes no sense. Macro facilities are a part of C, C++, assembler, and probably a lot of other languages. If I was asked this question I would politely explain this if I wanted the job. When no explanation was offered and the guy still insisted on an answer, I would probably walk away from this company in disgust.

There are explanations that could make sense of this question:

Macro is sometimes used a s a shorthand for 'macro assembler', in which case the question would be about C versus assembler. My standard answer is: "Assembler is better, on the condition that you get enough time. When was the last project you were given enough time?"

Another interpretation would be the use of macro's versus the use of functions, both within C. There are lots of texts about that, the general idea is that you always use functions, unless you really need to use a macro. And even then you should think twice.

Note that in neither case there is anything specific about embedded. That makes sense, because embedded is to wide a term to have any specific consequences on programming style. For very small systems (code size limited) the use of marcos instead of function calls could lead to code bloat. But carefull use of macros could reduce code size, so even then there is no definite answer.