Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-trace.H File Reference

Conditional tracing macros for debugging. More...

#include <iostream>
Include dependency graph for ah-trace.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AH_TRACE_JOIN_(a, b)   a ## b
 
#define AH_TRACE_JOIN(a, b)   AH_TRACE_JOIN_(a, b)
 
#define AH_TRACE_ONCE   AH_TRACE_JOIN(ah_trace_once_, __LINE__)
 
#define ah_trace_unless(out, C)
 
#define ah_trace_if(out, C)
 
#define ah_msg(out)    out << ""
 
#define ah_msg_if(out, C)
 
#define ah_msg_unless(out, C)
 

Detailed Description

Conditional tracing macros for debugging.

Provides ah_trace_unless and ah_trace_if macros that output file:line information when conditions are met. Useful for debugging without full assertion overhead.

Each conditional macro is a for of one iteration, which takes no else: an else written after an invocation belongs to the if around it, and one with no if around it does not compile. Its condition is evaluated once, and it converts to bool as that of an if does, so a scoped enumeration does not; it must be an expression, not a declaration as in if (auto e = f()).

Author
Leandro Rabindranath León

Definition in file ah-trace.H.

Macro Definition Documentation

◆ ah_msg

#define ah_msg (   out)     out << ""

Definition at line 73 of file ah-trace.H.

◆ ah_msg_if

#define ah_msg_if (   out,
  C 
)
Value:
for (bool AH_TRACE_ONCE = (C) ? true : false; AH_TRACE_ONCE; \
AH_TRACE_ONCE = false) \
[[unlikely]](out) << ""
#define AH_TRACE_ONCE
Definition ah-trace.H:61
size_t size_t int32_t * out
Definition ca-c-api.h:120

Definition at line 76 of file ah-trace.H.

◆ ah_msg_unless

#define ah_msg_unless (   out,
  C 
)
Value:
for (bool AH_TRACE_ONCE = not (C); AH_TRACE_ONCE; \
AH_TRACE_ONCE = false) \
[[unlikely]](out) << ""

Definition at line 81 of file ah-trace.H.

◆ ah_trace_if

#define ah_trace_if (   out,
  C 
)
Value:
for (bool AH_TRACE_ONCE = (C) ? true : false; \
__builtin_expect(AH_TRACE_ONCE, 0); AH_TRACE_ONCE = false) \
out << __FILE__ << ":" << __LINE__ << " | "

Definition at line 68 of file ah-trace.H.

◆ AH_TRACE_JOIN

#define AH_TRACE_JOIN (   a,
  b 
)    AH_TRACE_JOIN_(a, b)

Definition at line 60 of file ah-trace.H.

◆ AH_TRACE_JOIN_

#define AH_TRACE_JOIN_ (   a,
  b 
)    a ## b

Definition at line 59 of file ah-trace.H.

◆ AH_TRACE_ONCE

#define AH_TRACE_ONCE   AH_TRACE_JOIN(ah_trace_once_, __LINE__)

Definition at line 61 of file ah-trace.H.

◆ ah_trace_unless

#define ah_trace_unless (   out,
  C 
)
Value:
for (bool AH_TRACE_ONCE = not (C); \
__builtin_expect(AH_TRACE_ONCE, 0); AH_TRACE_ONCE = false) \
out << __FILE__ << ":" << __LINE__ << " | "

Definition at line 63 of file ah-trace.H.