summaryrefslogtreecommitdiffstats
path: root/src/lisiblestd/assert.h
blob: 15026f9af6b7d41bfadb3bb404cc866821103a60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef LSTD_ASSERT_H
#define LSTD_ASSERT_H

#include "log.h"

extern void exit(int);



#ifdef LSTD_PLATFORM_PLAYDATE
#include <pd_api.h>
extern PlaydateAPI* pd;
#define LSTD_ASSERT(expr)                                                      \
  do {                                                                         \
    if (!(expr)) {                                                             \
      pd->system->error("Assertion failed:\n\t%s", #expr);                     \
    }                                                                          \
  } while (0)

#define LSTD_UNIMPLEMENTED()                                                   \
  do {                                                                         \
      pd->system->error("Unimpemented code reached");                          \
  } while (0)
#else
#define LSTD_ASSERT(expr)                                                      \
  do {                                                                         \
    if (!(expr)) {                                                             \
      LOG_ERROR("Assertion failed:\n\t%s", #expr);                             \
      exit(1);                                                                 \
    }                                                                          \
  } while (0)

#define LSTD_UNIMPLEMENTED()                                                   \
  do {                                                                         \
    LOG_ERROR("Unimplemented code reached");                                   \
    exit(1);                                                                   \
  } while (0)
#endif

#endif // LSTD_ASSERT_H
Go back to lisible.xyz