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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm working on a code base which uses a compiler that has a basic type
__int32which is equivalent to aninton most platforms (i.e. 4-byte type). This type can be used whereintcan be used so you can have things liketypedef unsigned __int32 uint32;This causes problems because cppcheck views this as declaring a variable named
__int32of 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
podtypeconstruct 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 topodtypebut would introduce a basic/standard type.Any thoughts?
Thank you in advance!
Matt Markland
What happens if you have
#define __int32 int?
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#defineis a good one and would work in most cases, it doesn't work here.Matt Markland
Related ticket: https://trac.cppcheck.net/ticket/14245
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?
Creating a .cfg file with the necessary defines is probably the way to go.
I don't have a 4-byte type I can use in a
#defineto 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.