PDA

View Full Version : signal and slots



vermarajeev
16th October 2007, 09:09
Hello All,

//.h
class A
{
Q_OBJECT
public:
A(){}
public slots:
#ifdef SOMEMACRO
void slotA();
#endif
};
//.cpp
#ifdef SOMEMACRO
void A::slotA()
{
//..
}
#endif

If SOMEMACRO is "NOT DEFINED" will the above code compile?
In my case it doesn't compile. Why?
Is the moc_A.cpp file created before preprocessors being parsed by the compiler?

Thanks

Michiel
16th October 2007, 09:11
I think you just forgot the # of #ifdef.

marcel
16th October 2007, 09:15
ifdefs don't work in headers that need to be moc'ed!

vermarajeev
16th October 2007, 09:16
ifdefs don't work in headers that need to be moc'ed!

So mean to say, moc_A.cpp file is created before preprocessors being parsed by the compiler? M I right?

marcel
16th October 2007, 09:31
Of course it is. And moc doesn't do well with macros.