Menu

Support for compiler specific basic types

2025-11-05
2025-11-12
  • Matthew Markland

    I'm working on a code base which uses a compiler that has a basic type __int32 which is equivalent to an int on most platforms (i.e. 4-byte type). This type can be used where int can be used so you can have things like

    typedef unsigned __int32 uint32;

    This causes problems because cppcheck views this as declaring a variable named __int32 of type unsigned and the AST parsing blows up.

    Is there an extension point in cppcheck where I can teach it about new basic types? I know there is the podtype construct in libraries, but that doesn't exactly fit what I would like. I'd like to be able to add something in the platform file which would have a format similar to podtype but would introduce a basic/standard type.

    Any thoughts?

    Thank you in advance!

    Matt Markland

     
  • Andrew C Aitchison

    What happens if you have
    #define __int32 int
    ?

     
    • Matthew Markland

      I neglected to supply a key piece of information; on the platform/compiler in question sizeof(__int32) != sizeof(int) so the suggestion of using the #define is a good one and would work in most cases, it doesn't work here.

      Matt Markland

       
  • CHR

    CHR - 2025-11-06
     
    👍
    1
  • Matthew Markland

    I see the related ticket has been closed due to it being a Windows compatibility situation. My situation is not that. Should I reopen the existing ticket or open a new one?

     
  • CHR

    CHR - 2025-11-12

    Creating a .cfg file with the necessary defines is probably the way to go.

     
    • Matthew Markland

      I don't have a 4-byte type I can use in a #define to do the mapping. The compiler is truly supplying another base integral type with a sizeof(4) that I need to have cppcheck recognize in a way where it does all of its checking, unlike <podtype>. Other scanners I've used allow for the definition of extensions like this, but I can understand if it is not part of the design of cppcheck.

      We have come up with a very kludgy workaround using a mixture of the platform file and some defines, but we were hoping there was a better way.

       

Log in to post a comment.