Is it possible to "return" a string from a function-like macro? I know macros don't really "return" things, but is it possible to have the macro evaluate to a string?
For example, I have some code that takes a chess board square number (0...63) and converts it to "A1", "D1", etc. I was thinking of rewriting it as a macro, but I want to do things like this:
printf ("Square is %s\n",SN2ALG(44));
In other words, any place you'd have a string.
The actual code is something like
#define SN2ALG(x) concatenation of ((x >> 3)+'A') and (x & 7), yielding A3, D5, or whatever
...but of course, that doesn't work but sprintf requires a string name - it's not a drop-in escape mechanism.
#define SN2ALG(x) sprintf("%c%c",((x >> 3)+'A'), (x & 7))
I can certainly put it in a function, of course...just comparing options...though I don't think there is one in this case ;-)