Menu

cppcheck fails when files are missing from compile_commands.json

2023-08-02
2025-06-16
  • scott carver

    scott carver - 2023-08-02

    When running e.g.:
    cppcheck --project=compile_commands.json test.cpp

    And given a compile_commands.json file where some of the files do not exist, cppcheck always fails with an error of the form:
    cppcheck: error: '/path/to/some/file_that_doesnt_exist.cpp' from compilation database does not exist
    cppcheck: error: failed to load project 'compile_commands.json'. An error occurred.

    I wonder whether there's something obvious I'm missing here, since it's very common to have generated intermediate files in a compile_commands.json that may not be built in all cases? This error seems to suggest that cppcheck doesn't work with ANY project that has generated files, or in cases where ANY file is referenced in compile_commands but doesn't exist - both exceedingly common scenarios.

    This can be reproduced by adding a non-existent file to any compile_commands.json of any project and then running cppcheck with the --project command (I've tried this on several projects).

     
  • Daniel Marjamäki

    sorry about late reply. I have created this ticket: https://trac.cppcheck.net/ticket/13946

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.