free hit counter

Friday, April 21, 2006

What the hell is the ## doing in the middle of a C++ macro?

Funny me, I went searching all over google, google groups, and a9 for it. Since I only found scant uncommented references in code I figured it had to be something totally obvious.

So, going on the track that it must be something so basic that everyone knows it and so doesn't bother writing about it on the web I grabed my trusty K&R C book.

Right there in the index, and written about on page 90: the ## operator in a macro will concatenate two macro arguments. e.g

#define MAKE_NAME(x,y) x ## Y
MAKE_NAME(frank, 1) //will create frank1



Post a Comment

<< Home