Skip to content

Commit 6f59709

Browse files
Handle exename on macos (cppcheck-opensource#4071)
1 parent 449d351 commit 6f59709

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

cli/main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
static char exename[1024] = {0};
7777
#endif
7878

79+
#if defined(__APPLE__)
80+
#include <mach-o/dyld.h>
81+
82+
static char exename[1024] = {0};
83+
#endif
84+
7985
/**
8086
* Main function of cppcheck
8187
*
@@ -95,6 +101,11 @@ int main(int argc, char* argv[])
95101
GetModuleFileNameA(nullptr, exename, sizeof(exename)/sizeof(exename[0])-1);
96102
argv[0] = exename;
97103
#endif
104+
#if defined(__APPLE__)
105+
uint32_t size = sizeof(exename);
106+
_NSGetExecutablePath(exename, &size);
107+
argv[0] = exename;
108+
#endif
98109
// *INDENT-OFF*
99110
#ifdef NDEBUG
100111
try {

0 commit comments

Comments
 (0)