Originally Posted by
whiteflags
No, there is nothing missing. In my own tests, it produces the expected outcome. Maybe your window is closing before you can see the output?
yes; it runs. I am not sure why it did not earlier. I added some more stuff, and now I get error messages. Here is what I have:
Code:
#include <stdio.h>
int count, x;
#define printx(n) printint (x ## n)
#define printint(var) printf( # var " = %i\n", var)
int main(void)
{
count = 2;
x = 3;
printx (10);
printint (count);
}
Code:
$ gcc test.c -o test
test.c: In function 'main':
test.c:3:29: error: 'x10' undeclared (first use in this function)
#define printx(n) printint (x ## n)
^
test.c:4:48: note: in definition of macro 'printint'
#define printint(var) printf( # var " = %i\n", var)
^
test.c:9:1: note: in expansion of macro 'printx'
printx (10);
^
test.c:3:29: note: each undeclared identifier is reported only once for each function it appears in
#define printx(n) printint (x ## n)
^
test.c:4:48: note: in definition of macro 'printint'
#define printint(var) printf( # var " = %i\n", var)
^
test.c:9:1: note: in expansion of macro 'printx'
printx (10);
^
I tried declaring the variables globally. I am not sure what else to do.