PDA

View Full Version : Macros in the slot section



Caius Aérobus
30th April 2009, 12:54
Hello,
I would like to use a macro in the slot section but the moc preprocessor encapsulates it BEFORE the C++ preprocessor processes it, which leads to an error. How to cope with this issue?

Macro function:

#define SetFloatSlotMacro(name, arg) \
void Set##name(QString arg) {this->Set##name(arg.toFloat());}; \
void Set##name(float arg)

Resulting code in moc generated file:

case 4: { int _r = SetFloatSlotMacro((*reinterpret_cast< IdleToWalk(*)>(_a[1])),(*reinterpret_cast< speed(*)>(_a[2])));
if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break;
Error at compile time:

moc_Avatar.cpp:94:1: error: pasting "Set" and "(" does not give a valid preprocessing token

caduel
30th April 2009, 20:19
probably that can be achieved by adding a pre-processing step into the build process with qmake: qmake-environment-reference.html#customizing-makefile-output

Haven't tried myself yet, though.

Caius Aérobus
2nd May 2009, 11:30
probably that can be achieved by adding a pre-processing step into the build process with qmake: qmake-environment-reference.html#customizing-makefile-output

Haven't tried myself yet, though.

Hmmm, seems not to be easy, I suspect (hope) there is an easier way to cope with this issue...