WHY DEFINE GNUC

v1
Brett 2023-12-16 02:42:38 -05:00
parent a691ca76b0
commit 320a5af9b9
1 changed files with 6 additions and 6 deletions

View File

@ -11,13 +11,13 @@
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
#include <execinfo.h> #include <execinfo.h>
#include <cstdlib> #include <cstdlib>
#endif #endif
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
#define BLT_STACK_TRACE(number) void* ptrs[number]; \ #define BLT_STACK_TRACE(number) void* ptrs[number]; \
int size = backtrace(ptrs, number); \ int size = backtrace(ptrs, number); \
char** messages = backtrace_symbols(ptrs, size); char** messages = backtrace_symbols(ptrs, size);
@ -25,7 +25,7 @@
#define BLT_FREE_STACK_TRACE() free(messages); #define BLT_FREE_STACK_TRACE() free(messages);
#else #else
#define BLT_STACK_TRACE(number) void(); #define BLT_STACK_TRACE(number) void();
#define BLT_FREE_STACK_TRACE() void(); #define BLT_FREE_STACK_TRACE() void();
#endif #endif
@ -41,7 +41,7 @@ namespace blt {
void b_throw(const char* what, const char* path, int line) void b_throw(const char* what, const char* path, int line)
{ {
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
BLT_STACK_TRACE(50); BLT_STACK_TRACE(50);
BLT_ERROR("An exception '%s' has occurred in file '%s:%d'", what, path, line); BLT_ERROR("An exception '%s' has occurred in file '%s:%d'", what, path, line);
@ -54,7 +54,7 @@ namespace blt {
void b_assert_failed(const char* expression, const char* path, int line) void b_assert_failed(const char* expression, const char* path, int line)
{ {
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
BLT_STACK_TRACE(50); BLT_STACK_TRACE(50);
BLT_ERROR("The assertion '%s' has failed in file '%s:%d'", expression, path, line); BLT_ERROR("The assertion '%s' has failed in file '%s:%d'", expression, path, line);
@ -70,7 +70,7 @@ namespace blt {
{ {
if (messages == nullptr) if (messages == nullptr)
return; return;
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
for (int i = 1; i < size; i++){ for (int i = 1; i < size; i++){
int tabs = i - 1; int tabs = i - 1;
std::string buffer; std::string buffer;