Is there a way to remove text literals from binary versions when using boost :: log API?

boost 1.55 provides a logging API using the C ++ thread insert operator (otherwise called the left shift operator).

Although the syntax is convenient, I can't think of a way to drop debugging text literals from the executable.

Using MFC, for example, the TRACE macro ends up as an empty string in the release configuration.

Using TRACE (or any such macro function):

TRACE("This text literal shall only be found in debug configuration");

Using Boost API:

LOG_DEBUG << "This text literal shall only be found in debug configuration";

I tested (using Visual Studio 2010, full compiler optimization (/ Ox)) How to remove debug log statements from the program , but the literal ends in the executable in the release (which makes sense, as far as I could predict the result).

+4
2

, :

#ifdef _DEBUG
#define LOG(arg) LOG_DEBUG << arg
#else
#define LOG(arg)
#endif

LOG("This text literal shall only be found in debug configuration");

. - :

LOG("Answer = " << 42);
0

operator<< Visual Studio 2008. , , , . /OPT:REF ( ), .

, , - :

/DEBUG, /OPT NOREF ( REF), .

, , Release /OPT:REF , . , Visual Studio , /DEBUG ( , ), /OPT:REF , .

0

Source: https://habr.com/ru/post/1542392/


All Articles