Skip to content

Commit 365f605

Browse files
MarcusCalhoun-Lopezthezbyg
authored andcommitted
Allow build on macOS.
1 parent 4fdc322 commit 365f605

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

source/Paths.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <iostream>
2727
#if BOOST_OS_WINDOWS != 0
2828
#include <windows.h>
29+
#elif BOOST_OS_MACOS != 0
30+
#include <mach-o/dyld.h>
2931
#else
3032
#include <unistd.h>
3133
#endif
@@ -63,6 +65,17 @@ static std::string getExecutablePath() {
6365
buffer.resize(buffer.size() * 2);
6466
}
6567
}
68+
#elif BOOST_OS_MACOS != 0
69+
static std::string getExecutablePath() {
70+
uint32_t bufferSize = 4096;
71+
std::vector<char> buffer;
72+
buffer.resize(bufferSize);
73+
while (1) {
74+
if (_NSGetExecutablePath(buffer.data(), &bufferSize) == 0)
75+
return buffer.data();
76+
buffer.resize(bufferSize);
77+
}
78+
}
6679
#else
6780
#error getExecutablePath not implemented for current OS
6881
#endif

0 commit comments

Comments
 (0)