Exactly, macro is not necessary for programming languages. For example, Java works quite fine without macro. Usually macro makes code more clear and shorter, at the same time, more dangerous.
So, what’s the best way to use macro?
Let’s talk in code.
I use macros only in places where nothing else works.
One example is having an easy mapping from error values to strings, for example instead of
I use a simple macro like
so I can simplify this to
However, those cases are usually more for debugging.
Also, I’ve written a GLSL (OpenGL Shading Language) loop unrolling once using the boost preprocessor suite, which then could be used something like