Menu

Error suppressing

2014-12-10
2014-12-21
  • Jose Azevedo

    Jose Azevedo - 2014-12-10

    Hi Guys,
    I'm getting error id "obsoleteFunctionsgets" on my code and for several reasons I don't want to change it to fgets as it is suggested.
    I ran cppcheck and on the xml logfile i got "obsoleteFunctionsgets".
    I tried to inline suppress this error with:

    // cppcheck-suppress obsoleteFunctionsgets

    with no success.

    Any hint?

    thanks.

     
  • Daniel Marjamäki

    Use --inline-suppr on the command line also. Otherwise the comment is ignored.

    daniel@dator:~/cppcheck$ ./cppcheck --enable=all 1.c
    Checking 1.c...
    [1.c:4]: (style) Obsolete function 'gets' called. It is recommended to use the function 'fgets' instead.
    daniel@dator:~/cppcheck$ ./cppcheck --enable=all --inline-suppr 1.c
    Checking 1.c...
    daniel@dator:~/cppcheck$

    Personally.. I use --suppress or --suppressions-list instead of --inline-suppr. I don't like to clutter my code with such comments.

     
  • Darren Smith

    Darren Smith - 2014-12-17

    Hi ... using the inline suppression approach, is there any way to supress all cppchecks for that line? eg, something like:

    myarrayOfFive[10] = '\0';  /* cppcheck-suppress all */
    
     

    Last edit: Darren Smith 2014-12-17
  • Daniel Marjamäki

    Try:

    // cppcheck-suppress *
    
     
  • Darren Smith

    Darren Smith - 2014-12-21

    worked, thanks

     

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.