jeudi 21 octobre 2021

Replace C++ class/static method with preprocessor?

I'd like to use the built-in compiler checks to verify format strings of a custom logging framework to catch the odd runtime crash due to mismatching format string <-> parameters in advance.

Arguments of the custom C++ logging methods are identical to the printf() family so I was attempting to replace all calls to

MyLogger::Error(

with

fprintf(stderr,

Though unfortunately the (clang) preprocessor chokes on the scope resolution operator (::), i.e. instead of ULog::Warn( only the ULog substring is recognized:

#define MyLogger::Error( fprintf(stderr,

Any suggestions on how to make this work much appreciated.

Aucun commentaire:

Enregistrer un commentaire