File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -277,8 +277,33 @@ int main() {
277277
278278 try
279279 {
280- // Build command with proper quoting for cross-platform compatibility
281- std::string exe = " ./cppcheck" ;
280+ // Try multiple possible locations for the cppcheck executable
281+ std::vector<std::string> possibleExes = {
282+ " ./cppcheck" ,
283+ " ../bin/cppcheck" ,
284+ " ../../bin/cppcheck" ,
285+ " cppcheck" // fallback to PATH
286+ };
287+
288+ std::string exe;
289+ for (const auto & possibleExe : possibleExes) {
290+ // Test if executable exists and is accessible
291+ #ifdef _WIN32
292+ std::string testCmd = " \" " + possibleExe + " \" --version >nul 2>&1" ;
293+ #else
294+ std::string testCmd = possibleExe + " --version >/dev/null 2>&1" ;
295+ #endif
296+ if (system (testCmd.c_str ()) == 0 ) {
297+ exe = possibleExe;
298+ break ;
299+ }
300+ }
301+
302+ if (exe.empty ()) {
303+ std::remove (filename.c_str ());
304+ return " " ;
305+ }
306+
282307 std::string args = " --output-format=sarif --enable=all " + filename;
283308
284309#ifdef _WIN32
You can’t perform that action at this time.
0 commit comments