From c3724ec506a9e3a4b23a145a733050c17321da9d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 31 Mar 2018 02:12:44 -0400 Subject: [PATCH] implement os_self_exe_path in the c++ compiler for darwin ported from the zig std lib this fixes looking for zig std lib at runtime on darwin --- src/os.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/os.cpp b/src/os.cpp index 90eecef3cf..de1a1f21d2 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -45,6 +45,7 @@ typedef SSIZE_T ssize_t; #if defined(__MACH__) #include #include +#include #endif #if defined(ZIG_OS_WINDOWS) @@ -923,7 +924,13 @@ int os_self_exe_path(Buf *out_path) { } #elif defined(ZIG_OS_DARWIN) - return ErrorFileNotFound; + uint32_t u32_len = 0; + int ret1 = _NSGetExecutablePath(nullptr, &u32_len); + assert(ret1 != 0); + buf_resize(out_path, u32_len); + int ret2 = _NSGetExecutablePath(buf_ptr(out_path), &u32_len); + assert(ret2 == 0); + return 0; #elif defined(ZIG_OS_LINUX) buf_resize(out_path, 256); for (;;) {