Change type of bit field - uint32 not acceptable type

In my scan of C code, the rule “Bit fields should be declared with appropriate types” was violated may times due to using type uint32. This is defined in the header but is still not being considered an acceptable type: “The use of any type other than signed short, unsigned short, signed char, unsigned char, signed int, unsigned int or _Bool for a bit field is implementation-defined, and therefore not portable.” I cannot edit this rule’s parameter(s) for acceptable formats like I can with some other rules. What can I do to get types like uint32, uint64, etc. to be accepted as unsigned ints?

Using SonarQube v. 8.3.1, SonarScanner v. 4.3.0

Hello @tlangley,

Thanks for contacting us.

The fact that uint32 is a standard type and that it is defined in the system headers does not imply that all compilers support bit fields on this type in a portable way.
You cannot add types to the portable types list. It is defined by the standard only.

This rule is about portability.
If you do not care about portability, you can disable the rule.

I hope it helps.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.