-
Notifications
You must be signed in to change notification settings - Fork 1.5k
#14173: Add Valuetype type and sign for stdint macros #7869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e1bf2a5 to
7a1ea72
Compare
|
Still needs a ticket and we should also file a follow-up about |
7a1ea72 to
cf8ae54
Compare
lib/symboldatabase.cpp
Outdated
| valuetype.type = ValueType::Type::CHAR; | ||
| else if (macroWidth == 16) | ||
| valuetype.type = ValueType::Type::SHORT; | ||
| else if (macroWidth == 32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to compare the platform sizes. An int can be 16 bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably put the logic into platform.cpp so it can be re-used.
I also found the "ticket" - it's the extensive list in a TODO in Platform::getLimitsDefines().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual ticket: https://trac.cppcheck.net/ticket/11928#comment:4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also just generate defines which would simplify the code. Here's the compiler output for reference (the macros will be mapped to the non-reserved ones in the headers):
$ clang++ -dM -E - < /dev/null | grep _C\(
#define __INT16_C(c) c
#define __INT32_C(c) c
#define __INT64_C(c) c##L
#define __INT8_C(c) c
#define __INTMAX_C(c) c##L
#define __UINT16_C(c) c
#define __UINT32_C(c) c##U
#define __UINT64_C(c) c##UL
#define __UINT8_C(c) c
#define __UINTMAX_C(c) c##UL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably put the logic into platform.cpp so it can be re-used.
hmm if we put it in platform.cpp then that file must include symboldatabase.h :-(
how about putting it in ValueType instead the symboldatabase already has a Settings dependency anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also just generate defines which would simplify the code. Here's the compiler output for reference (the macros will be mapped to the non-reserved ones in the headers):
I don't want to reuse those macros they will make it impossible to implement the Misra C rules. The code INT8_C(1000) would be preprocessed into 1000..
|
yes a ticket is needed. 👍 @firewave for your information I asked swasti to implement this and my motivation is that we need it for misra c. it would have been nice to replace |
53a1a31 to
690fa50
Compare
690fa50 to
876563b
Compare
876563b to
62c30ad
Compare
|



No description provided.