move defines to c++

v1
Brett 2023-09-07 00:23:13 -04:00
parent 465f1a4fc8
commit 215220f98b
2 changed files with 18 additions and 18 deletions

View File

@ -7,24 +7,6 @@
#ifndef BLT_ASSERT_H
#define BLT_ASSERT_H
#ifdef __GNUC__
#include <execinfo.h>
#include <cstdlib>
#endif
#ifdef __GNUC__
#define BLT_STACK_TRACE(number) void* ptrs[number]; \
int size = backtrace(ptrs, number); \
char** messages = backtrace_symbols(ptrs, size);
#define BLT_FREE_STACK_TRACE() free(messages);
#else
#define BLT_STACK_TRACE(number) void();
#define BLT_FREE_STACK_TRACE() void();
#endif
namespace blt
{
void printStacktrace(char** messages, int size, const char* path, int line);

View File

@ -10,6 +10,24 @@
#include <iomanip>
#include <sstream>
#ifdef __GNUC__
#include <execinfo.h>
#include <cstdlib>
#endif
#ifdef __GNUC__
#define BLT_STACK_TRACE(number) void* ptrs[number]; \
int size = backtrace(ptrs, number); \
char** messages = backtrace_symbols(ptrs, size);
#define BLT_FREE_STACK_TRACE() free(messages);
#else
#define BLT_STACK_TRACE(number) void();
#define BLT_FREE_STACK_TRACE() void();
#endif
namespace blt {
static inline std::string _macro_filename(const std::string& path){