From 34ae6d96d541ff7289cfba800659b66446d8ea8f Mon Sep 17 00:00:00 2001 From: zackiloco Date: Tue, 23 May 2023 15:13:17 +0200 Subject: [PATCH] Move `#include` to top level and exclude Clang from compiler version check. Clang cannot handle being included in a namespace, which is also unadvised see: https://softwareengineering.stackexchange.com/a/335261. Using the fallback is only meant for GCC 10, but Clang defines `__GNUC__ = 4` so exclude Clang. --- src/btop.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/btop.cpp b/src/btop.cpp index fd6b38d..1ec2a10 100644 --- a/src/btop.cpp +++ b/src/btop.cpp @@ -37,6 +37,11 @@ tab-size = 4 #include #include #endif +#if !defined(__clang__) && __GNUC__ < 11 + #include +#else + #include +#endif #include #include @@ -336,14 +341,12 @@ namespace Runner { atomic coreNum_reset (false); //* Setup semaphore for triggering thread to do work -#if __GNUC__ < 11 - #include +#if !defined(__clang__) && __GNUC__ < 11 sem_t do_work; inline void thread_sem_init() { sem_init(&do_work, 0, 0); } inline void thread_wait() { sem_wait(&do_work); } inline void thread_trigger() { sem_post(&do_work); } #else - #include std::binary_semaphore do_work(0); inline void thread_sem_init() { ; } inline void thread_wait() { do_work.acquire(); }