M
mark.bergman
I am porting some old code from Digital Unix to Linux using token
pasting, which is failing to compile (code simplified):
#define DEBUG(strg,v) printf("debugoutput: "##strg##".\n", v);
main()
{
int x = 5;
DEBUG("variable x is %d",x);
}
Compiler gives the following output:
b.c:6:1: pasting ""debugoutput: "" and ""variable x is %d"" does not
give a valid preprocessing token
b.c:6:1: pasting ""variable x is %d"" and "".\n"" does not give a
valid preprocessing token
I am trying to understand the concept of "valid preprocessing token",
but also would like to know how I can achieve what the code tries to
do
Mark
pasting, which is failing to compile (code simplified):
#define DEBUG(strg,v) printf("debugoutput: "##strg##".\n", v);
main()
{
int x = 5;
DEBUG("variable x is %d",x);
}
Compiler gives the following output:
b.c:6:1: pasting ""debugoutput: "" and ""variable x is %d"" does not
give a valid preprocessing token
b.c:6:1: pasting ""variable x is %d"" and "".\n"" does not give a
valid preprocessing token
I am trying to understand the concept of "valid preprocessing token",
but also would like to know how I can achieve what the code tries to
do
Mark