Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why adding #define contsants for initializing a const is breaking rule 10.3 ?
#1
I have the folowing code :

Code:
#define CONST1 556U
#define CONST2 420U

uint16_t const MY_var1 = CONST1;
uint16_t const MY_var2 = CONST2;
uint16_t const MY_varTotal = (CONST1 + CONST2);

And FlexeLint for C/C++ (Unix) Vers. 9.00L gives me he following message:


uint16_t const MY_varTotal = (CONST1 + CONST2);
Note 9034: Expression assigned to a narrower or different essential type [MISRA 2012 Rule 10.3, required]
[/code]


I do not understand the reasoning why rule 10.3 is violated.
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)