couldn't figure out what the \ means after each line in the definition of M(op). What is that for?
Backslash at the (very) end of the line allows the macro definition to continue to the next line. Otherwise it would end at the newline.
Also what is meant by first line
printf(" %-22s", #op);
?
The #
sign is the "stringize operator"; it turns the macro argument op
into a string literal by putting double-quotes around it.
Aside from that, %-22s
tells printf
to print a string with left-justification in 22 characters.
Along with this answer if you can point to some good source or tut. for C Prepocessor, it will be appreciated.
Learning the preprocessor "just happens"… it is a tool of last resort, so expertise in it should not usually be actively sought. I've written a C++11/C99 preprocessor — and it's harder than it sounds — but I have not encountered a good tutorial.