I was looking at some coding done in a header file of a program installed on my PC & i found this :
# define A( CLASS ) \
B(CLASS) \
void *D(const C*to);
can anybody tell me what this means?
what are those slashes for & why hasnt all of this written in 1 line?
what does (CLASS) mean over here?
& why is there so much spacing done?
The backslashes are there to “protect” the newline — the preprocessor will throw away both the
\and the newline when reading in the file, putting the entire thing on one logical line. (Well, it’ll also emit#linemarkups so the compiler can generate decent error messages too.)Someone thought that layout was more legible than this:
If you imagine that
B,D, andCare probably replaced with something else in the file, it’ll look a bit like this in the output:It must have made more sense to them, as they wrote the macro, to instead “see” it like this:
I’m not sure it is an improvement (and I think I hate the style), but hopefully it makes sense now.