3 ms·
Is the problem the use of a macro, which isn't as robust as a template, or is there a problem with the macro? All I can figure is there could be an accidental d
by blovescoffee 6y ago
Is the problem the use of a macro, which isn't as robust as a template, or is there a problem with the macro? All I can figure is there could be an accidental dereference instead of multiply.
- virtue3 6y agoThe problem is macro expansion is not (potentially) what you think it is: MULTIPLY(2+3,4+5) that expands in 2+34+5 (and not into: (2+3)(4+5)). To have the latter, you should define: #define MULTIPLY(a,b) ((a)*(b)) https://stackoverflow.com/questions/14041453/why-are-preprocessor-macros-evil-and-what-are-the-alternatives#:~:text=The%20trouble%20with%20macros%20is,comes%20down%20to%20personal%20preference https://stackoverflow.com/questions/14041453/why-are-preproc....