
Originally Posted by
wysota
I suggest you change your macros to functions. Then you'll only have to provide headers with prototypes of those functions and the implementation that uses the Logger class (together with the header for that class) can remain hidden (and then you don't have to expose the class using LOGGER_EXPORT).
I'd wish to do it that way,but I can't :/ all because of that __LINE__ and __FILE__,it has to be placed at the line of using a macro.
Hmmmm...or there is a solution,instead of
#define LOGDEBUG_Logger(text,loggerId,level) Logger::printLog(text,loggerId,__LINE__,__FILE__,level);
#define LOGDEBUG_Logger(text,loggerId,level) Logger::printLog(text,loggerId,__LINE__,__FILE__,level);
To copy to clipboard, switch view to plain text mode
use something like:
void someGlobalFunction(params);//declaration there,definition inside let's say logger.cpp and therefore inside the .dll file
#define LOGDEBUG_Logger(text,loggerId,level) someGlobalFunction(text,loggerId,__LINE__,__FILE__,level);
void someGlobalFunction(params);//declaration there,definition inside let's say logger.cpp and therefore inside the .dll file
#define LOGDEBUG_Logger(text,loggerId,level) someGlobalFunction(text,loggerId,__LINE__,__FILE__,level);
To copy to clipboard, switch view to plain text mode
and inside it I shoud invoke my Logger::printLog
Added after 14 minutes:
Well,thanks Wysota,that idea of using a global function instead of Logger::printLog helped to hide all the complexity.But now I have an issue with linker:
loggerdlltest.obj : error LNK2019: unresolved external symbol _logPrint referenced in function "public: __thiscall LoggerDLLTest::LoggerDLLTest(class QWidget *,class QFlags<enum Qt::WindowType>)" (??0LoggerDLLTest@@QAE@PAVQWidget@@V?$QFlags@W4Win dowType@Qt@@@@@Z)
C:\Program Files\Microsoft Visual Studio .NET 2003\Projects\LoggerDLLTest\Release\LoggerDLLTest. exe : fatal error LNK1120: 1 unresolved externals
How to make it work?I changed my file logger_global.h to:
extern "C" void __cdecl logPrint
(const QString &text,
const QString &loggerID,
int line
=0,
const QString &file
=QString(),
char level
=maxLevel,
char type
=0);
#define LOGDEBUG_Logger(text,loggerId,level) logPrint(text,loggerId,__LINE__,__FILE__,level);
extern "C" void __cdecl logPrint(const QString &text,const QString &loggerID,int line=0,const QString &file=QString(),char level=maxLevel,char type=0);
#define LOGDEBUG_Logger(text,loggerId,level) logPrint(text,loggerId,__LINE__,__FILE__,level);
To copy to clipboard, switch view to plain text mode
Bookmarks