Menu

unusedFunction false positive

2023-11-10
2023-12-15
  • Andrea Cassioli

    Andrea Cassioli - 2023-11-10

    Hi I have a project where several function are wrongly marked as unused. For instance in source/a/b/x.cpp

    InputMetrics CalculateInputMetrics(const InputData& ds) {
    // some code
    }
    

    then in another file source/a/y.cpp

    void LogInputDataMetrics(const InputData& input_data) {
         auto metric = f(CalculateInputMetrics(input_data));
         // do stuff
    }
    

    CalculateInputMetrics is flagged as unused.

     
  • Daniel Marjamäki

    Sorry for late reply. hmm.. I don't get this false positive:

    $ ~/.cppcheck/cppcheck-2.12.0 --enable=all a.cpp b.cpp
    Checking a.cpp ...
    1/2 files checked 35% done
    Checking b.cpp ...
    2/2 files checked 100% done
    b.cpp:1:0: style: The function 'LogInputDataMetrics' is never used. [unusedFunction]
    void LogInputDataMetrics(const InputData& input_data) {
    ^
    

    do you use some similar cppcheck options?

     

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.