summaryrefslogtreecommitdiffstats
path: root/src/controller/custom.h
blob: 7f849fc55fd6dd87ee95cb3b51eeaad3b9bb88f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef CUSTOM_H_
#define CUSTOM_H_

#include <glib.h>

static inline gboolean g_warn_if_expr (gboolean condition,
                                       const char *pretty_func,
                                       const char *expression) {
  if G_UNLIKELY(condition) {
      g_log (G_LOG_DOMAIN,
             G_LOG_LEVEL_CRITICAL,
             "%s: `%s' condition reached",
             pretty_func,
             expression);
    }

  return condition;
}

#define g_warn_if(expr) g_warn_if_expr((expr), __PRETTY_FUNCTION__, #expr)

#endif