Handle exename on macos (#4071)

This commit is contained in:
Martin Delille 2022-05-08 13:57:42 +02:00 committed by GitHub
parent 449d351095
commit 6f597091a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -76,6 +76,12 @@
static char exename[1024] = {0};
#endif
#if defined(__APPLE__)
#include <mach-o/dyld.h>
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 {