the problem of "#define hash_hash # ## #"

f z zhangjiakouzf@yahoo.com.cn
Sat Jan 24 06:58:00 GMT 2009


Hi , 

Anybody could help to explain the following code which is the example in C99 std!

/***********************************************************/
4 EXAMPLE In the following fragment:
#define hash_hash # ## #
#define mkstr(a) # a
#define in_between(a) mkstr(a)
#define join(c, d) in_between(c hash_hash d)
char p[] = join(x, y); // equivalent to
// char p[] = "x ## y";
The expansion produces, at various stages:
join(x, y)
in_between(x hash_hash y)
in_between(x ## y)
mkstr(x ## y)
"x ## y"
In other words, expanding hash_hash produces a new token, consisting of two adjacent sharp signs, but
this new token is not the ## operator.
/**********************************************************/

Where define this syntax "#define hash_hash # ## #" in std?

In C99 std, we all know that "'##' cannot appear at either end of a macro expansion". 

In this definiation of macro , the "hash_hash" are defined with "# ## #",but I don't know what is the mean of the first and last sharp(#).



      ___________________________________________________________ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/



More information about the Gcc-help mailing list