For learning and demonstrating, I need a macro which prints its parameter and evaluates it. I suspect it is a very common case, may be even a FAQ but I cannot find actual references.
My current code is:
#define PRINT(expr) (fprintf(stdout, "%s -> %d\n", __STRING(expr), (expr)))
and then:
PRINT(x & 0x01);
It works fine but I am not sure of the legal status of the __STRING macro, specially since it is in the private __ namespace.
So, my questions:
- Is there a better way to write this macro?
- Is __STRING standard/great/evil?
- How to use existing search tools to find about __STRING? SO's search engine just searches anything containing string :-(