authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-31 02:12:44-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-31 02:12:44-04:00
logc3724ec506a9e3a4b23a145a733050c17321da9d
tree9eeef4d13b4888507cfb502791266bacbde7d304
parent5d5feb11deb797bbecb8f3676457a74056f09496

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

1 files changed, 8 insertions(+), 1 deletions(-)

src/os.cpp+8-1
......@@ -45,6 +45,7 @@ typedef SSIZE_T ssize_t;
4545#if defined(__MACH__)
4646#include <mach/clock.h>
4747#include <mach/mach.h>
48#include <mach-o/dyld.h>
4849#endif
4950
5051#if defined(ZIG_OS_WINDOWS)
......@@ -923,7 +924,13 @@ int os_self_exe_path(Buf *out_path) {
923924 }
924925
925926#elif defined(ZIG_OS_DARWIN)
926 return ErrorFileNotFound;
927 uint32_t u32_len = 0;
928 int ret1 = _NSGetExecutablePath(nullptr, &u32_len);
929 assert(ret1 != 0);
930 buf_resize(out_path, u32_len);
931 int ret2 = _NSGetExecutablePath(buf_ptr(out_path), &u32_len);
932 assert(ret2 == 0);
933 return 0;
927934#elif defined(ZIG_OS_LINUX)
928935 buf_resize(out_path, 256);
929936 for (;;) {