Skip to content

Commit

Permalink
Only enable linux stacktraces when using glibc (#69)
Browse files Browse the repository at this point in the history
This is a follow-up to previous attempt #90
Stacktraces use glibc-specific extension execinfo.h, so currently loguru
compilation will fail with other C libraries like musl with an error
like:

loguru/loguru.cpp:103:18: fatal error: execinfo.h: No such file or directory
  103 |         #include <execinfo.h>  // for backtrace

This change adds a check on __GLIBC__ before enabling backtraces, and
simplifies the logic around it a bit: first checking Windows, then
glibc, then other systems
  • Loading branch information
voyageur committed Apr 12, 2022
1 parent 89f06b3 commit c242ca3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions loguru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,24 @@

// TODO: use defined(_POSIX_VERSION) for some of these things?


#if defined(_WIN32) || defined(__CYGWIN__)
#define LOGURU_PTHREADS 0
#define LOGURU_WINTHREADS 1
#ifndef LOGURU_STACKTRACES
#define LOGURU_STACKTRACES 0
#endif
#elif defined(__rtems__) || defined(__ANDROID__) || defined(__FreeBSD__)
#define LOGURU_PTHREADS 1
#define LOGURU_WINTHREADS 0
#ifndef LOGURU_STACKTRACES
#define LOGURU_STACKTRACES 0
#endif
#else
#define LOGURU_PTHREADS 1
#define LOGURU_WINTHREADS 0
#ifndef LOGURU_STACKTRACES
#define LOGURU_STACKTRACES 1
#ifdef __GLIBC__
#ifndef LOGURU_STACKTRACES
#define LOGURU_STACKTRACES 1
#endif
#else
#ifndef LOGURU_STACKTRACES
#define LOGURU_STACKTRACES 0
#endif
#endif
#endif

Expand Down

0 comments on commit c242ca3

Please sign in to comment.