lundi 7 janvier 2019

effective C Preprocessor macros without #define

I want use Logger class for logging In C++, this class has static and use like :

auto logger = Logger::GetInstance();
logger->Log(message, FileName, Line)

for filename and Line number I can use __ FILE__ and __ LINE__ macro but everywhere I use this logger Must be write this macro. That's My First Problem

I found a way, that is use #define like this:

#define LOG(message) Logger::getInstance()->Log(message, __ FILE__, __ LINE__)

and with this function I don't need write this preprocessor. use #define is My secound Problem as Scott Meyers say in this book.

Is there any way for avoid from #define and don't write every time this preprocessor?

Aucun commentaire:

Enregistrer un commentaire