Menu

checking json project: different results for different starting directories

vilox
2021-01-29
2021-01-29
  • vilox

    vilox - 2021-01-29

    json project indicates directory: and file: for each compilation unit, so I we should be able to run

    $ cppcheck --project=/path/to/bar.json

    and do not care of what directory is current for cppcheck now.
    However the results of checking may differ for different starting working directory.
    Let wrap into json project the command line

    $ cppcheck -DANY -I /tmp/R/include -I /tmp/R/bar/part_1 /tmp/R/bar/part_2/bar.c

    from [preprocessor includes wrong header files] topic of this forum.

    $ cat bar.json

    [
        {
            "arguments": [
                "gcc",
                "-DANY",
                "-I/tmp/R/include",
                "-I/tmp/R/bar/part_1"
            ],
            "directory": "/tmp/R/bar",
            "file": "part_2/bar.c"
        }
    ]
    

    Then

    $ cd /
    host:/$ cppcheck --project=/tmp/R/chkr/bar.json
    Checking /tmp/R/bar/part_2/bar.c ...
    /tmp/R/include/foo.h:7:0: error: #error Foo was not configured [preprocessorErrorDirective]
    # error Foo was not configured
    ^

    but

    host:/$ cd /tmp/R/bar
    host:bar$ cppcheck --project=/tmp/R/chkr/bar.json
    Checking part_2/bar.c ...
    Checking part_2/bar.c: ANY=1...
    host:bar$

     
  • Daniel Marjamäki

    hmm I will check..

     
  • Daniel Marjamäki

    Thanks! I have created https://trac.cppcheck.net/ticket/10149 for this

     

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.