Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to build on MacOS #45

Open
usermarqueemark opened this issue Jun 30, 2022 · 1 comment
Open

Failure to build on MacOS #45

usermarqueemark opened this issue Jun 30, 2022 · 1 comment

Comments

@usermarqueemark
Copy link

Pulled "main" today and included in a C++ program which I am compiling on macOS.

I had 2 issues, the first is as follows:

fmtlog/fmtlog.h:101:28: error: expected ';' at end of declaration list
  static void preallocate() FMT_NOEXCEPT;
                           ^
                           ;

I rectified this adding #define FMT_NOEXCEPT to my source file prior to #include <fmtlog/fmtlog.h> I now have:

#define FMTLOG_HEADER_ONLY
#define FMT_HEADER_ONLY
#define FMT_NOEXCEPT
#include <fmtlog/fmtlog.h>
#include <fmt/format.h>

The second issue is with macOS where the functionsyscall is deprecated:

fmtlog/fmtlog-inl.h:294:44: warning: 'syscall' is deprecated: first deprecated in macOS 10.12 - syscall(2) is unsupported; please switch to a supported interface. For SYS_kdebug_trace use kdebug_signpost(). [-Wdeprecated-declarations]
   uint32_t tid = static_cast<uint32_t>(::syscall(SYS_gettid));
                                           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:746:6: note: 'syscall' has been explicitly marked deprecated here
int      syscall(int, ...);
         ^
1 warning generated.

I have patched locally by adding the following:

diff --git a/fmtlog-inl.h b/fmtlog-inl.h
index 9d85e51..34e1c11 100644
--- a/fmtlog-inl.h
+++ b/fmtlog-inl.h
@@ -38,6 +38,10 @@ SOFTWARE.
 #include <unistd.h>
 #endif

+#ifdef __APPLE__
+#include <pthread.h>
+#endif
+
 namespace {
 void fmtlogEmptyFun(void*) {
 }
@@ -290,6 +294,9 @@ public:
     fmtlog::threadBuffer = new fmtlog::ThreadBuffer();
 #ifdef _WIN32
     uint32_t tid = static_cast<uint32_t>(::GetCurrentThreadId());
+#elif __APPLE__
+    uint64_t tid = 0;
+    pthread_threadid_np(nullptr, &tid);
 #else
     uint32_t tid = static_cast<uint32_t>(::syscall(SYS_gettid));
 #endif
@MengRao
Copy link
Owner

MengRao commented Sep 11, 2022

FMT_NOEXCEPT issue has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants