-1

I receive the cppcheck: No C or C++ source files found. error even though the file in question is present in the directory I am searching in.

This is the command I am running:

subprocess.call('cppcheck --dump --max-ctu-depth=0' + cpp_file_path, shell = True)

In which I want to produce a dump file, and suppress any deeper program analysis (this is why N=0 in --max-ctu-depth=N). The directory I am also going into, the cpp_file_path has a little over 10,000 files. Is there a flag I can use with the cppcheck utility to ensure that it is searching through the entire directory? Why would the error appear if that .cpp file is present in the directory specified? I have confirmed those files do exist multiple times.

greendaysbomb
  • 364
  • 2
  • 6
  • 23
  • 1
    `=0' + cpp_file_path` doesn't this need a space? – KamilCuk Sep 02 '21 at 23:17
  • Oh my gosh. That was such a silly error that I could find even after hours of staring at my code. I just reran my code and it's getting through checking more files now...I will update if there are any more issues! – greendaysbomb Sep 02 '21 at 23:20
  • I recommend against stacking questions on questions. It makes for really bad questions. If you want to resurface this question and make it into a a useful question, I'd delete it first. Wait too long and it'll be closed as a typo, and after that you can't really do much with it. – user4581301 Sep 02 '21 at 23:24

1 Answers1

0

You passed:

cppcheck --dump --max-ctu-depth=0cpp_file_path

Prefer using shell=False and passing an array. This will also protect you against filename with spaces.

subprocess.call(['cppcheck', '--dump', '--max-ctu-depth=0', cpp_file_path])
KamilCuk
  • 120,984
  • 8
  • 59
  • 111