[Qt-interest] "#ifdef unix" usage problem in header file for moc file

Paul Floyd paulf at free.fr
Wed Dec 9 17:27:37 CET 2009


Quoting navid navid <n_nnavid at yahoo.com>:

> Hello,
>
> when I include a signal definition in header file of sampleclass.cpp:
> #ifdef unix
>   void sampleSignal(int ireport);
> #endif
>
> I cant see it in related moc file, and receive
> "undefined reference to `SampleClass::sampleSignal(int)'"
> error.
>
> I sure the compiler goes to it, so any syntax error within it, is reported:
> #ifdef unix
>   :
> #endif
>
> at the being time, I changed "#ifdef unix" to "#ifndef win32", to overcome
> the problem.
>
> where is the problem? is it a bug?

Firstly, using the macro 'unix' isn't portable.

Your problem is that you're trying to declare a class member function with a
standalone function declaration. This won't work. You need to include the file
with the definition of class SampleClass.

A+
Paul
-- 
Paul Floyd   http://paulf.free.fr



More information about the Qt-interest-old mailing list