|
Packit Service |
8bf002 |
/* n_24.c: # operator in macro definition. */
|
|
Packit Service |
8bf002 |
|
|
Packit Service |
8bf002 |
#include "defs.h"
|
|
Packit Service |
8bf002 |
|
|
Packit Service |
8bf002 |
main( void)
|
|
Packit Service |
8bf002 |
{
|
|
Packit Service |
8bf002 |
fputs( "started\n", stderr);
|
|
Packit Service |
8bf002 |
|
|
Packit Service |
8bf002 |
/* 24.1: */
|
|
Packit Service |
8bf002 |
#define str( a) # a
|
|
Packit Service |
8bf002 |
assert( strcmp( str( a+b), "a+b") == 0);
|
|
Packit Service |
8bf002 |
|
|
Packit Service |
8bf002 |
/* 24.2: White spaces between tokens of operand are converted to one space.
|
|
Packit Service |
8bf002 |
*/
|
|
Packit Service |
8bf002 |
assert( strcmp( str( ab /* comment */ +
|
|
Packit Service |
8bf002 |
cd ), "ab + cd") == 0);
|
|
Packit Service |
8bf002 |
|
|
Packit Service |
8bf002 |
/* 24.3: \ is inserted before \ and " in or surrounding literals and no
|
|
Packit Service |
8bf002 |
other character is inserted to anywhere. */
|
|
Packit Service |
8bf002 |
assert( strcmp( str( '"' + "' \""), "'\"' + \"' \\\"\"") == 0);
|
|
Packit Service |
8bf002 |
|
|
Packit Service |
8bf002 |
/* 24.4: Line splicing by <backslash><newline> is done prior to token
|
|
Packit Service |
8bf002 |
parsing. */
|
|
Packit Service |
8bf002 |
assert( strcmp( str( "ab\
|
|
Packit Service |
8bf002 |
c"), "\"abc\"") == 0);
|
|
Packit Service |
8bf002 |
|
|
Packit Service |
8bf002 |
/* 24.5: Token separator inserted by macro expansion should be removed.
|
|
Packit Service |
8bf002 |
(Meanwhile, tokens should not be merged. See 21.2.) */
|
|
Packit Service |
8bf002 |
#define xstr( a) str( a)
|
|
Packit Service |
8bf002 |
#define f(a) a
|
|
Packit Service |
8bf002 |
assert( strcmp( xstr( x-f(y)), "x-y") == 0);
|
|
Packit Service |
8bf002 |
|
|
Packit Service |
8bf002 |
fputs( "success\n", stderr);
|
|
Packit Service |
8bf002 |
return 0;
|
|
Packit Service |
8bf002 |
}
|
|
Packit Service |
8bf002 |
|