Menu

cppcheck -I parameter

2016-11-29
2016-11-29
  • Alexander Nikitin

    Hello cppcheck gurus!
    Got the following problem (tried to get rid of missingIncludeSystem, but got another problems :) :
    1. OS Windows 7 x86
    2. cppcheck x86 1.73

    commandline:
    cppcheck.exe ./src -I"C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE" --suppress=purgedConfiguration --report-progress --force --inline-suppr --enable=all --verbose --xml-version=2

    source file (src/main.cxx) :
    //------------------------------------------

    #include <stdio.h>
    int main(int , char **) {
        return 0;
    }
    

    //------------------------------------------

    output: (bunch of similar lines pointing to VC\INCLUDE\swprintf.inl and VC\INCLUDE\stdio.h)
    <error id="va_list_usedBeforeStarted" severity="error" msg="va_list '_Arglist' used before va_start() was called." verbose="va_list '_Arglist' used before va_start() was called." cwe="664">
    <location file0="src\\main.cxx" file="C:\\Program Files\\Microsoft Visual Studio 10.0\\VC\\INCLUDE\\swprintf.inl" line="42"/>
    </error>
    <error id="va_list_usedBeforeStarted" severity="error" msg="va_list '_ArgList' used before va_start() was called." verbose="va_list '_ArgList' used before va_start() was called." cwe="664">
    <location file0="src\\main.cxx" file="C:\\Program Files\\Microsoft Visual Studio 10.0\\VC\\INCLUDE\\stdio.h" line="483"/>
    </error>

    question:
    Is it possible to leave -I parameter in cppcheck arguments, but somehow either completely disable it's checking or disable cheking per file.

    PS while playing around with parameters I found a bug in cppcheck x86 1.76.1
    the following code (I figured out that I have to add ifdef/endif to reproduce cppcheck x86 1.73 behaviour) :

    #include <stdio.h>
    #ifdef _WIN32
    #endif
    int main(int , char **) {
        return 0;
    }
    

    with the following commandline:
    cppcheck.exe ./src -I"C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE" --suppress=purgedConfiguration --report-progress --force --inline-suppr --enable=all --verbose --xml-version=2

    results in the following output (see file="zzz\Program Files... instead of file="C:\Program Files... Where zzz - is a folder in which ./src resides)

        <error id="va_list_usedBeforeStarted" severity="error" msg="va_list &apos;_Arglist&apos; used before va_start() was called." verbose="va_list &apos;_Arglist&apos; used before va_start() was called." cwe="664">
            <location file0="src\main.cxx" file="zzz\Program Files\Microsoft Visual Studio 10.0\VC\include\swprintf.inl" line="66"/>
        </error>
    
     
  • Alexander Nikitin

    Ok, got it working in 1.75 :
    --suppress=:"C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\swprintf.inl"
    --suppress=
    :"C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\stdio.h"

    partial path is also possible :
    --suppress=*:"VC\INCLUDE\swprintf.inl"

     
    • Alexander Nikitin

      Oops, sorry ...
      partial path doesn't work - only full path works

       

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.