1
votes

A static code analysis tool shows me that I have an unsequenced function calls for a define. Want to get rid of the warning.

It complains that I use Logging() and get_id() (two functions, only one allowed) in the last define.

#define MSG_FORMAT(x) " [thread: " << std::this_thread::get_id() << "] [" << __func__ << "] " << x

#define SYSTEM_LOG(x) loa::peer::Logging() << MSG_FORMAT(x)

How can I modify the defines to avoid the warning? As you see I have already tried to split them into two defines.

This looks like a really bad idea. Why do you use macros? Please create an MCVE. How do you use the macro? Where do you use the macro? With what parameter? What is the context? code analysis tool shows me - what tool? and what is the exact warning message, including filename and line number? - KamilCuk
The unsequencedness shouldn't matter. Silly warning. Just disable it! - Lightness Races in Orbit
@KamilCuk "Why do you use macros?" - should be obvious from the code that he wants to include the function name in every log message, which necessitates a macro. - vll
I'm guessing that you want to allow further chaining of <<? (Such as SYSTEM_LOG("foo") << 123 << "abc";) - molbdnilo
Since macros are resolved at (or, traditionally, before) compile time, splitting the macro can’t possibly introduce ordering on a runtime operation. - Davis Herring