
aliasing single quotes in macros
Quote:
> You wouldn't use a character constant. Remember that character constants
> are simply integer values. You can write simply:
> #define SPECIAL_CHAR 012 /* Octal integer constant */
> char a = SPECIAL_CHAR;
This is the best solution in the current context. I should have mentioned
that I also want to embed SPECIAL_CHAR into constant strings so here is
the complete problem I face. I need to get preprocessor output of:
#define SPECIAL_CHAR 012 /* or char constant? */
char a = 012; /* or a = '\012' */
const char *b = "some text with a char \012";
from source similar to:
#define SPECIAL_CHAR 012 /* or char constant? */
#define M(text,char) /* unknown macro definition here */
char a = 012; /* or a = '\012' */
const char *b = M("some text with a char ",SPECIAL_CHAR);
I've been only able to do one or the other assignment but not both. It
seems to boil down to being able to produce the character \ or ' in a
macro without the preprocessor complaining or producing wrong output.
Thanks,
/cc