Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#define with two token after the pattern

Every reference on google only shows easy examples, I have this case on a code:

#define XHANDLER(A,B,H) X_TO_BUS_HANDLER(A,B,H) X_FROM_BUS_HANDLER(A,B,H)

namespace{
   X_TO_BUS_HANDLER( some::SomeClassX,
                     bus::SomeBus,
                     foo::SomeHandler );

Does any one know how this define works? One pattern and two token-lists? References please.

I egrepED the code but only found X_TO_BUS_HANDLER been used.

like image 677
Rodrigo Gurgel Avatar asked Dec 12 '22 20:12

Rodrigo Gurgel


1 Answers

It works like any other define - whenever the preprocessor encounters XHANDLER, it replaces it with X_TO_BUS_HANDLER(A,B,H) X_FROM_BUS_HANDLER(A,B,H) (and parameters).

In your snippet, the macro isn't used.

But something like

XHANDLER(some::SomeClassX, bus::SomeBus, foo::SomeHandler) 

would be equivalent to

X_TO_BUS_HANDLER(some::SomeClassX, bus::SomeBus, foo::SomeHandler) X_FROM_BUS_HANDLER(some::SomeClassX, bus::SomeBus, foo::SomeHandler)
like image 55
Luchian Grigore Avatar answered Dec 21 '22 02:12

Luchian Grigore