Implemented assert()

This commit is contained in:
2022-06-16 14:17:32 +01:00
parent 29ff102f3b
commit f00e74260d
2 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
#ifndef PHOTON_ASSERT_H_
#define PHOTON_ASSERT_H_
#define assert(x) if (!(x)) { __assert_fail(#x, __FUNCTION__, __FILE__, __LINE__); }
extern void _Noreturn __assert_fail(const char *, const char *, const char *, int);
#endif

View File

@@ -0,0 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
extern void _Noreturn __assert_fail(const char *exp, const char *func, const char *file, int line)
{
printf("Assertion failed: (%s), function %s, file %s, line %d\n", exp, func, file, line);
abort();
}