Menu

--include option doesn't work?

il--ya
2019-12-02
2019-12-09
  • il--ya

    il--ya - 2019-12-02

    I cannot get --include=<file> option to work. It seems that it is just silently ignored. Dumping preprocessed output with -E shows that specified file is not preincluded. Any advice?</file>

     
  • il--ya

    il--ya - 2019-12-02

    Apparently, cppcheck is case-sensitive when it comes to --include file names. Took me a good few hours to figure out. Would be nice to get an error message at least, when pre-include file could not be found.

     

    Last edit: il--ya 2019-12-02
  • versat

    versat - 2019-12-03

    I agree, this is not very user friendly.
    IMHO it is an issue with simplecpp that is part of Cppcheck, so I created an issue there: https://github.com/danmar/simplecpp/issues/183

     
  • versat

    versat - 2019-12-09

    Just a short update:
    "simplecpp" now issues an error when an explicitly included file can not be included.
    I have created a PR that uses the new functionality from "simplecpp" so Cppcheck also exits with an error when "--include=" does not work.
    Something like this is then issued by Cppcheck for example when "blah1.h" does not exist:

    $ ./cppcheck --include=blah1.h foo.c  -E
    foo.c:1:0: error: Can not open include file 'blah1.h' that is explicitly included. [preprocessorErrorDirective]
    int main()
    ^
    

    Thank you for this valuable feedback. I hope the error message is helpful now. If you have any other issues or ideas for Cppcheck do not hesitate to write about it.

     
    👍
    1
    • Daniel Marjamäki

      Hmm.. maybe it's unfortunate that the location points out code in a source file. I don't remember if we can give a "noloc" location.

       
      • versat

        versat - 2019-12-09

        In simplecpp I have not found a way to do this, in Cppcheck it is possible by simply using an empty string instead of the file name.
        It would look like this then:

        $ ./cppcheck --include=blah1.h foo.c
        Checking foo.c ...
        nofile:0:0: error: Can not open include file 'blah1.h' that is explicitly included. [preprocessorErrorDirective]
        
         

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.