My problem is quite simple. I want the following macro
#define PROXYPASS(name, param) \
void MyClass::sl_name(param _param) { \
emit name(_param); \
}
to expand PROXYPASS(clientAdded, Client*)
to:
void MyClass::sl_clientAdded(Client* _param) { \
emit clientAdded(_param); \
}
but since it ain't working i.e. it still shows just sl_name
instead of sl_clientAdded
. So, this is what I'm using:
#define PROXYPASS(name, param) \
void MyClass::sl_ ## name(param _param) { \
emit ## name(_param); \
}
It works fine, other than the fact that it expands to:
void MyClass::sl_clientAdded(Client* _param) { \
emitclientAdded(_param); \
}
Everything is fine other than the fact that there is no space between emit
and clientAdded
i.e. it expands to emitclientAdded
instead of emit clientAdded
. So how do I go about doing it? Is there a way to add spaces, or must I look for another way. A lot of googling has got my hopes down due to the following statement: Whether it [gcc pre-processor] puts white space between the tokens is undefined.
My other failed attempts include
emit ## ## name(_param);
emit ## /* */ ## name(_param);
emit ## \ ## name(_param);
emit /* */ ## name(_param);
emit ## space ## name(_param); [#define space \ ]
Any help is greatly appreciated.
NOTE: Preprocessor output and macro expansion checked using gcc -E myclass.cpp
.