Menu

support for noreturn annotation in code

2021-10-21
2021-10-22
  • david ingamells

    david ingamells - 2021-10-21

    Hi,
    We commonly use our own "Crash" function to abort a program as a wrapper around abort(). This is annotated for gcc as

    #ifdef __GNUC__
        __attribute__ ((noreturn))
    #endif
    

    It seems that cppcheck does not process this. I know that the "noreturn" annotation is available in the library config files, but I was hoping for a way to keep that property within the header file the code itself.

    Also the manual chapter "Library configuration" is very brief and incomplete (e.g. there is nothing further about loading after the manual says "They can be loaded as described below"), so I don't know how to tell cppcheck to look for a config file in different locations, or even if this is possible.

    Any feedback welcome,
    thanks.

     
  • Paul Fultz

    Paul Fultz - 2021-10-21

    Cppcheck does use the noreturn attribute, but checking for __GNUC__ wont make it available for cppcheck.

     
  • Daniel Marjamäki

    Yes. Do you provide -D__GNUC__ flag somehow in Cppcheck analysis? Can you give some example code that does not work as expected?

     
  • david ingamells

    david ingamells - 2021-10-22

    I have tested with the -D__GNUC__ and that does do what I want ... 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.