Menu

With --project set, '-I' option might be ignored.

wy163
2026-01-18
2026-01-21
  • wy163

    wy163 - 2026-01-18

    Hi,
    In the file cppcheck/lib/cppcheck.cpp:

    unsigned int CppCheck::check(const FileSettings &fs)
    {
        // TODO: move to constructor when CppCheck no longer owns the settings
        if (mSettings.checks.isEnabled(Checks::unusedFunction) && !mUnusedFunctionsCheck)
            mUnusedFunctionsCheck.reset(new CheckUnusedFunctions());
    
        Settings tempSettings = mSettings; // this is a copy
        if (!tempSettings.userDefines.empty())
            tempSettings.userDefines += ';';
        if (mSettings.clang)
            tempSettings.userDefines += fs.defines;
        else
            tempSettings.userDefines += fs.cppcheckDefines();
        tempSettings.includePaths = fs.includePaths;
        tempSettings.userUndefs.insert(fs.undefs.cbegin(), fs.undefs.cend());
    

    Maybe there is a problem with the code "tempSettings.includePaths = fs.includePaths;".
    Why not append fs.includePaths to tempSettings.includePaths.

     

    Last edit: wy163 2026-01-18
  • wy163

    wy163 - 2026-01-21

    Hi, I think this may be a bug.
    For example, with the command "cppcheck --project=/path/compile_commands.json -I /include_path main.c", the include_path will not take effect.

     

    Last edit: wy163 2026-01-21

Log in to post a comment.