K
Klaus Siegesleitner
Hi all!
sorry, my first posting to this newsgroup - hope everything works fine...
I'm looking for a macro that converts an octal number assigned to a
preprocessor symbol (via a simple #define) into a string-fragment that can
be added/embedded to an new string literal.
This string-fragment shall consist of two characters, both defined as octal
numbers:
the first octal number \001 (acting as an escape symbol) and
the second octal number that has been passed to the macro via its defined
preprocessor symbol.
example:
#define SYMBOL_ID_SUN 010
#define SYMBOL_ID_RAIN 011
#define SYMBOL_ID_FOG 012
#define CONVERT(arg) <whatever does the conversion>
char string[] = "the wether is " CONVERT(SYMBOL_ID_FOG) " today.";
should result in:
"the wether is \001\012 today"
I tried something like
#define CONVERT(arg) "\001"##str
or
#define CONVERT(arg) "\001"##'\'##arg
or
....
but most of the time got troubles because of the interpretation of the \ as
a linebreak.
any c-preprocessor expert here that can help??
thanks a lot,
klaus!
p.s.: if possible also reply to (e-mail address removed)
sorry, my first posting to this newsgroup - hope everything works fine...
I'm looking for a macro that converts an octal number assigned to a
preprocessor symbol (via a simple #define) into a string-fragment that can
be added/embedded to an new string literal.
This string-fragment shall consist of two characters, both defined as octal
numbers:
the first octal number \001 (acting as an escape symbol) and
the second octal number that has been passed to the macro via its defined
preprocessor symbol.
example:
#define SYMBOL_ID_SUN 010
#define SYMBOL_ID_RAIN 011
#define SYMBOL_ID_FOG 012
#define CONVERT(arg) <whatever does the conversion>
char string[] = "the wether is " CONVERT(SYMBOL_ID_FOG) " today.";
should result in:
"the wether is \001\012 today"
I tried something like
#define CONVERT(arg) "\001"##str
or
#define CONVERT(arg) "\001"##'\'##arg
or
....
but most of the time got troubles because of the interpretation of the \ as
a linebreak.
any c-preprocessor expert here that can help??
thanks a lot,
klaus!
p.s.: if possible also reply to (e-mail address removed)