olvaffe / percetto

Apache License 2.0
19 stars 10 forks source link

TRACE_EVENT expands to 3 statements #18

Open olvaffe opened 3 years ago

olvaffe commented 3 years ago

It seems TRACE_EVENT expands to 3 statements. That might not work with

if (some_condition)
    TRACE_EVENT(...);

without braces.

Wallbraker commented 3 years ago

You can fix that with a do { /* ...what was in TRACE_EVENT before... */ } while (false) statement.

olvaffe commented 3 years ago

That will fail

{
  TRACE_EVENT(...);
  function_that_is_slow_and_is_to_be_traced();
}
Wallbraker commented 3 years ago

Oh you are right, there really is no way around it.