In said:
Sort of....
#include <stdio.h>
#define NUMBER1 30
#define NUMBER2 50
#define SUM (NUMBER1+NUMBER2)
#define STRING1 "Byte: \\x30"
#define STRING2 "Byte: \\x50"
#define NUM(x) #x
#define STRINGx(x) "Byte: \\x"##NUM(x)
Nice try, but it's undefined behaviour:
3 For both object-like and function-like macro invocations, before
^^^^^^
the replacement list is reexamined for more macro names to
replace, each instance of a ## preprocessing token in the
replacement list (not from an argument) is deleted and the
preceding preprocessing token is concatenated with the following
preprocessing token. Placemarker preprocessing tokens are
handled specially: concatenation of two placemarkers results in
a single placemarker preprocessing token, and concatenation of a
placemarker with a non-placemarker preprocessing token results
in the non-placemarker preprocessing token. If the result is
^^^^^^^^^^^^^^^^
not a valid preprocessing token, the behavior is undefined. The
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
resulting token is available for further macro replacement. The
order of evaluation of ## operators is unspecified.
So, the preprocessor concatenates "Byte: \\x" and NUM and ends up with
"Byte: \\x"NUM which is not a valid preprocessing token, hence undefined
behaviour. Some preprocessors just go on and do what you intended, which
is allowed by undefined behaviour, gcc's is more friendly and it diagnoses
the code.
Fortunately, the ## operator in your macro was a mistake in the first
place: you don't want to create a new preprocessing token out of two
preprocessing tokens. All you want to achieve is generating two adjacent
string literals, that will be spliced together in translation phase 6:
#define STRINGx(x) "Byte: \\x" NUM(x)
Dan