views:

901

answers:

2

Using the QT Visual studio integration, adding a new QT class adds two separate moc.exe generated files - one for debug and one for release (and one for any other configuration currently existing). Yet the two eventual generated files seem to be identical.

On the other hand when adding a UI class, the uic.exe generated files don't have this separation and are the same file for all configurations.

Does anybody have an idea why there's a need for a separate moc file for every configuration? When is there a difference between the two?

+4  A: 

My guess would be that separate debug and release versions are needed because the moc output is generated from user-defined source code. So the moc output might be different between debug and release builds if the preprocessed class source differs between debug and release (for example, a signal that exists only in the debug build).

This doesn't apply to the uic-generated files because those are generated from the .ui XML, which can't vary between debug and release configurations.

Andrew Medico
+2  A: 

Moc parses the source for pre-processor directives. So if you had a header file like this:

class Test : public QObject
{
    Q_OBJECT
public:
     Test();    
public slots:

#ifndef DEBUG
     void Foo();
#endif
};

Then the slot Foo will only exist in the release build and not the debug build. Moc will generate different moc.cpp files depending on whether the DEBUG (in this case) symbol is set.

David Dibben