From 6f597091a4d2c77087caa4d340112bd600b71c1b Mon Sep 17 00:00:00 2001 From: Martin Delille Date: Sun, 8 May 2022 13:57:42 +0200 Subject: [PATCH] Handle exename on macos (#4071) --- cli/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cli/main.cpp b/cli/main.cpp index ca48497d2..dae782ce6 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -76,6 +76,12 @@ static char exename[1024] = {0}; #endif +#if defined(__APPLE__) +#include + +static char exename[1024] = {0}; +#endif + /** * Main function of cppcheck * @@ -95,6 +101,11 @@ int main(int argc, char* argv[]) GetModuleFileNameA(nullptr, exename, sizeof(exename)/sizeof(exename[0])-1); argv[0] = exename; #endif +#if defined(__APPLE__) + uint32_t size = sizeof(exename); + _NSGetExecutablePath(exename, &size); + argv[0] = exename; +#endif // *INDENT-OFF* #ifdef NDEBUG try {