From db5daa20ee5e95b80e0faf53574caf656db6bc87 Mon Sep 17 00:00:00 2001 From: gardners Date: Wed, 1 Oct 2014 09:28:56 +0930 Subject: [PATCH] fix OSX build errors. --- os.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/os.c b/os.c index 41194db5..88ecef5f 100644 --- a/os.c +++ b/os.c @@ -361,7 +361,13 @@ ssize_t get_self_executable_path(char *buf, size_t len) return read_symlink("/proc/self/path/a.out", buf, len); #elif defined (__APPLE__) uint32_t bufsize = len; - return _NSGetExecutablePath(buf, &bufsize) || len == 0 ? bufsize : -1; + // OSX complains if the ? : operator returns fields with different signedness + // so we cast the uint32_t bufsize to signed. We should really check to make + // sure that _NSGetExecutablePath doesn't return a value in bufsize that would + // be negative when cast. + ssize_t s = _NSGetExecutablePath(buf, &bufsize); + assert(((int32_t)bufsize)>=0); + return ( s || len == 0 ) ? (int32_t)bufsize : -1; #else #error Unable to find executable path #endif