Customizing size of datatypes for specific target architectures

Dear fellow developers,

I am using SQ analyzing my projects, written in C and C++. Target is a Texas Instruments TMS320F2837xD. Toolchain is c2000 (TI v22.6.1.LTS).

My problem is, that SQ doesn’t seem to recognize sizes of data types like char, short, long, etc. correctly. For example, I got the following issue reported by SQ:

To me, this looks like a ‘false positive’, because “uint32_t” equivalents to “unsigned long” and is 32Bit!

There are other issues concerning “char” and “uint16_t” (unsigned short), which is the data type with minimum size in the TMS.

So, how can I solve this? Any idea would be very appreciated!

I have already looked for my target architecture in the language-settings in the configuration section, but did not found it or anything like. :confused:

Most regards,

Thomas

Hi Thomas,

Welcome to the community and thanks for this report!

Can you give your context for this? Specifically, what version of SonarQube are you using?

 
Thx,
Ann

Hi Ann,

thank you for your fast reply,

I’m using SQ Developer Editionv2025.4.2 (112048).

We are trying to implement an embedded project in plain C but avoiding usage of any standard headers like stdint.h etc., thus we have made our own data-type header files (*.h).

I think, the main issue here is, that SQ doesn’t recognize the target’s architecture (TI’s TMS320F28F37xD), e.g. the size of data primitives. But this doesn’t explain, why uint32_t == unsigned long is not being treated as 32Bit?! :confused:

The ‘false positives’, as far, as I can think about it, seem to occur, when masking and binary shifting is taking place (as it can be seen by my example code snippet above).

However, maybe I’m wrong, and had to adjust my code in order to solve these issues?!

Thanks in advance,

Thomas

Hi Thomas,

And what rule(s) are you seeing raising false positives in this case? Since you’re not on the latest version, I’d like to see if there have been updates to the rule since 2025.4.

 
Thx,
Ann

Hi Ann,

the specific rule here is Rule ID:c:S3949.

But this isn’t the only rule affected! Others are cpp:S5494, c:S5276, c:S3949 and cpp:S5028

I’ve discussed to my superiors using newer version of SQ.

Maybe, the rules can directly adjusted? (For example, telling, that basic data-size is 16Bit, unsigned long being treated as 32Bit… etc.?)

Regards,

Thomas

1 Like

Hi Thomas,

Thanks! That’s helpful. I’ll flag this for the language experts.

 
Ann

1 Like

Hello @bartzick,

Can you please share the value of CHAR_BIT in your toolchain’s compiler with us?

Thanks,

Hi!

Our basic datatype setting is as follows:

  • unsigned char: 16Bit == CHAR_BIT
  • unsigned short: 16Bit equivalents to “uint16_t”
  • unsigned int: 16Bit equivalents to “int16_t”
  • unsigned long: 32Bit equivalents to “uint32_t”
  • unsigned long long: 64Bit equivalents to “uint64_t”

Please consider, smallest unit is always of size 16Bit! There are no “byte” (8Bit)-sizes supported by the target’s architecture.

Most regards,

Thomas

Hello @bartzick

Thanks for the info. This is a known issue with C2000, and I’ve added your report to the existing JIRA ticket

I will update this thread as soon as it’s resolved.

Thanks,

1 Like