My Qt project is linking to a library that is linux only. When a project starts under linux, I want the signal to be triggered by an event using the type defined in this library. However, the complication that I have is that the project must also be built on Windows. Obviously, this signal and the slot will not catch it in Windows, and this is wonderful. However, I found problems with the Qt moc tool that does not recognize the existence of #ifdef __linux__ around code that emits a signal. My code is as follows:
[SomeFile.h]
#ifdef __linux__ signals: void SomeSignal(SomeTypeDefinedInTheLinuxLibrary); #endif
[SomeFile.cpp]
#ifdef __linux__ emit SomeSignal(someObject); #endif
When I try to compile this with g ++, I get the error: SomeFile.cpp:(.text+0x858c): undefined reference to SomeFile::SomeSignal(SomeTypeDefinedInTheLinuxLibrary)
Any ideas on how to get moc and #ifdefs to play well together?
source share