Menu

Cppcheck 2.4.1 is unable to get compiler specific defines

Krishna
2021-05-17
2021-06-18
  • Krishna

    Krishna - 2021-05-17

    Hi,
    We have a macro which are defined based on the toolchain(CC_ARM, __ARMCC_VERSION, __GNUC, ICCARM Etc). below is the snippet of how it is defined.

    #if defined(ICCARM)
    #define DISABLE_WARNING(x) DO_PRAGMA(diag_suppress = x)
    #endif

    And passing compile_commands.json to the cppcheck and seeing the error
    DISABLE_WARNING(WARN_UNALIGNED_STRUCT)<--- There is an unknown macro here somewhere. Configuration is required. If DISABLE_WARNING is a macro then please configure it.

    This issue is not appearing with cppcheck 1.88 version. if I add manually -D__ICCARM__ in compile_commands.json it is not throwing any error. This proving that cppcheck unable to get the compiler defined macro -D__ICCARM__.

    How to resolve this issue?

     

    Last edit: Krishna 2021-05-17
  • Daniel Marjamäki

    hmm.. could you show a piece of your compile_commands.json?

    I guess it's enough with one item in the list. Please attach it so it doesn't get changed by some wiki formatting etc..

     
  • Krishna

    Krishna - 2021-05-20

    Please find the attachment.

     
  • Krishna

    Krishna - 2021-05-29

    Hi Daniel,

    Can you please reply with suggestions?

     
  • Daniel Marjamäki

    hmm.. I am not sure what to do. One possible quick fix is that you create a file iccarm.cfg :

    <?xml version="1.0">
    <def format="2">
      <define name="__ICCARM__" value="1"/>
    </def>
    

    Then you can add a --library=iccarm.cfg on the command line and Cppcheck should understand this..

    But that is a "hack" solution I don't really like it. The --library was not really meant to handle this particular use case. I think we should provide some better configuration.

     
  • Krishna

    Krishna - 2021-06-18

    Hi Daniel,

    Thanks for reply.

    Yes, the above solution wouldn't work for us.

    This issue is not there in 1.88v. Is this a bug in 2.4.1v?

    Is there a way to raise bug to fix?

    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.