A
Amp Sand
I'm studying how C preprocessor works and i've found this example on
wikipedia
#define FOO bar
#define _QUOTEME(x) #x
#define QUOTEME(x) _QUOTEME(x)
in this way # operator can be used to quote the value of a macro and
not its parameter. I don't understand how macro expansion works....fo
example:
1. printf("FOO=%s\n", QUOTEME(FOO));
2. printf("FOO=%s\n", _QUOTEME(FOO)); (underscore in _QUOTEME(FOO) is
due to convention or to something else?)
3. printf("FOO=%s\n", _QUOTEME(bar));
4. printf("FOO=%s\n",bar);
In this way the correct value is obtained, but i don't unterstand why
step 3 is done before step 4
Any help?
wikipedia
#define FOO bar
#define _QUOTEME(x) #x
#define QUOTEME(x) _QUOTEME(x)
in this way # operator can be used to quote the value of a macro and
not its parameter. I don't understand how macro expansion works....fo
example:
1. printf("FOO=%s\n", QUOTEME(FOO));
2. printf("FOO=%s\n", _QUOTEME(FOO)); (underscore in _QUOTEME(FOO) is
due to convention or to something else?)
3. printf("FOO=%s\n", _QUOTEME(bar));
4. printf("FOO=%s\n",bar);
In this way the correct value is obtained, but i don't unterstand why
step 3 is done before step 4
Any help?