1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-05 18:08:55 +03:00
mal/impls/cpp/Debug.h
Joel Martin 8a19f60386 Move implementations into impls/ dir
- Reorder README to have implementation list after "learning tool"
  bullet.

- This also moves tests/ and libs/ into impls. It would be preferrable
  to have these directories at the top level.  However, this causes
  difficulties with the wasm implementations which need pre-open
  directories and have trouble with paths starting with "../../". So
  in lieu of that, symlink those directories to the top-level.

- Move the run_argv_test.sh script into the tests directory for
  general hygiene.
2020-02-10 23:50:16 -06:00

46 lines
956 B
C

#ifndef INCLUDE_DEBUG_H
#define INCLUDE_DEBUG_H
#include <stdio.h>
#include <stdlib.h>
#define DEBUG_TRACE 1
//#define DEBUG_OBJECT_LIFETIMES 1
//#define DEBUG_ENV_LIFETIMES 1
#define DEBUG_TRACE_FILE stderr
#define NOOP do { } while (false)
#define NOTRACE(...) NOOP
#if DEBUG_TRACE
#define TRACE(...) fprintf(DEBUG_TRACE_FILE, __VA_ARGS__)
#else
#define TRACE NOTRACE
#endif
#if DEBUG_OBJECT_LIFETIMES
#define TRACE_OBJECT TRACE
#else
#define TRACE_OBJECT NOTRACE
#endif
#if DEBUG_ENV_LIFETIMES
#define TRACE_ENV TRACE
#else
#define TRACE_ENV NOTRACE
#endif
#define _ASSERT(file, line, condition, ...) \
if (!(condition)) { \
printf("Assertion failed at %s(%d): ", file, line); \
printf(__VA_ARGS__); \
exit(1); \
} else { }
#define ASSERT(condition, ...) \
_ASSERT(__FILE__, __LINE__, condition, __VA_ARGS__)
#endif // INCLUDE_DEBUG_H