Multiline Macro Compilation Errors
C++, Programming March 18th, 2009Sometimes you just need to write macros in your C/C++ code. And sometimes, they get long and you want to split them on multiple lines for reasons of readibility.
I admit, that I only seldomly use multiline macros. But today something new came to my mind. I created a simple multiline macro, e.g. something similar to this:
-
#define MYMACRO(a, b) {
-
a = a+b;
-
b = b+a; }
Nothing difficult or wrong on the first sight! Right? Okay but I got hundreds of compilation errors!
After trying around some time I noticed that it is not allowed to put a space behind the slash, i.e. ” is okay and ‘ ‘ is not.
So if you encounter the same error - welcome to the club …. tststs one never stops learning





Recent Comments