Skip to content

Conversation

@swasti16
Copy link
Contributor

@swasti16 swasti16 commented Oct 3, 2025

No description provided.

@swasti16 swasti16 force-pushed the swasti/addon287 branch 3 times, most recently from e1bf2a5 to 7a1ea72 Compare October 3, 2025 11:45
@firewave
Copy link
Collaborator

firewave commented Oct 3, 2025

There should be a ticket related to this - but it possible we forgot to file one when those macros were dropped in #5527 - after they were moved in #5421.

@firewave
Copy link
Collaborator

firewave commented Oct 3, 2025

Still needs a ticket and we should also file a follow-up about {U}INTMAX_C() (see https://en.cppreference.com/w/c/types/integer.html).

valuetype.type = ValueType::Type::CHAR;
else if (macroWidth == 16)
valuetype.type = ValueType::Type::SHORT;
else if (macroWidth == 32)
Copy link
Owner

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.

Copy link
Collaborator

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().

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

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

Copy link
Owner

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.

Copy link
Owner

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..

@danmar
Copy link
Owner

danmar commented Oct 3, 2025

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 UINT32_C(1) with 1U or (uint32_least_t)1 or something like that but that solution makes it hard to implement some Misra C checkers for proper usage of these macros unfortunately.

@swasti16 swasti16 changed the title Add Valuetype type and sign for stdint macros #14173: Add Valuetype type and sign for stdint macros Oct 3, 2025
@swasti16 swasti16 force-pushed the swasti/addon287 branch 4 times, most recently from 53a1a31 to 690fa50 Compare October 3, 2025 16:59
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 5, 2025

@danmar danmar merged commit 68454d6 into danmar:main Oct 5, 2025
53 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants