Guett_31
2nd August 2013, 06:32
Hi,
I would like to redirect all the debug message to a file. In order to do so, I call 'qInstallMsgHandler' in the main.cpp to install a message handler that would do the job but the compiler complains and gives me a C3861: 'qInstallMsgHandler': identifier not found error message.
qInstallMsgHandler is declared in the QtGlobal header and QtGlobal is included in my main.ccp, so it should find it. Could someone help me to understand that error, please? Thanks.
#include <QApplication>
#include <QtGui>
#include <QtGlobal>
#include "mainwindow.h"
#define DEBUG_TEST
#ifdef DEBUG_TEST
void crashMessageOutput(QtMsgType type, const char *msg)
{
switch (type)
{
case QtDebugMsg:
fprintf(stderr, "Debug: %s\n", msg);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s\n", msg);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s\n", msg);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s\n", msg);
abort();
}
}
#endif
int main(int argc, char *argv[])
{
#ifdef DEBUG_TEST
qInstallMsgHandler(crashMessageOutput);
#endif
QApplication app(argc, argv);
MainWindow theMainWindow;
theMainWindow.show();
return app.exec();
}
I would like to redirect all the debug message to a file. In order to do so, I call 'qInstallMsgHandler' in the main.cpp to install a message handler that would do the job but the compiler complains and gives me a C3861: 'qInstallMsgHandler': identifier not found error message.
qInstallMsgHandler is declared in the QtGlobal header and QtGlobal is included in my main.ccp, so it should find it. Could someone help me to understand that error, please? Thanks.
#include <QApplication>
#include <QtGui>
#include <QtGlobal>
#include "mainwindow.h"
#define DEBUG_TEST
#ifdef DEBUG_TEST
void crashMessageOutput(QtMsgType type, const char *msg)
{
switch (type)
{
case QtDebugMsg:
fprintf(stderr, "Debug: %s\n", msg);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s\n", msg);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s\n", msg);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s\n", msg);
abort();
}
}
#endif
int main(int argc, char *argv[])
{
#ifdef DEBUG_TEST
qInstallMsgHandler(crashMessageOutput);
#endif
QApplication app(argc, argv);
MainWindow theMainWindow;
theMainWindow.show();
return app.exec();
}