Menu

Is it possible CppCheck ignores code between Macros?

2020-04-07
2020-04-07
  • Shaghayegh Sheykholeslami

    Hi everybody.
    I check juliet c/c++ 1.2 files with cppcheck by this command:

    cppcheck   --xml --xml-version=2 testcases/CWE123_Write_What_Where_Condition 2>report.xml
    

    It's ok I get the warnings and errors.but my code has some macro like these:

    #ifndef OMITBAD
    
    void bad()
    {
        badStruct data;
        badStruct &dataRef = data;
        linkedList head = { &head, &head };
        /* This simulates a Microsoft-style linked list insertion */
        data.list.next = head.next;
        data.list.prev = head.prev;
        head.next = &data.list;
        head.prev = &data.list;
        {
    #ifdef _WIN32
            WSADATA wsaData;
            int wsaDataInit = 0;
    #endif
    and .......
    

    Now I want to Cppcheck ignore my codes that they are between macro "#ifndef OMITBAD".
    I try -U or -D but they don't work.

    Is it possible ignore code between some macros in CppCheck?

    Thank you.

     
  • Daniel Marjamäki

    As far as I see the code should be skipped if you try -DOMITBAD. Doesn't that work?

    Do you think the output is wrong somehow when options -E -DOMITBAD is used?

     
  • Shaghayegh Sheykholeslami

    I did a silly mistake ! I check the files and save on the same file I think something happen like cache when I delete previouse report and check with -DOMITBAD it worked!!!
    Thank you for your response.

     

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.