I have the following:
typedef struct
{
uint8_t BlockID;
uint32_t Copies;
uint16_t Size;
}NVMM_ConfigType;
const NVMM_ConfigType NvmmCnf_Layout[6] =
{
{ 1, 1, 4},
{ 2, 3, 4},
{ 5, 5, 16},
{ 10, 1, 4},
{ 11, 2, 32},
{ 13, 1, 100},
};
Which seems fine to me, but, MISRA-C is giving the following error:
MISRA C:2012 rule 10.3 violation: [R] The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category
I've tried to figure out why is this happening but I just can see it. Also the build results are plagued with this errors on similar situations and I don't know why.
Does anybody know what's going on?
EDIT: I have also tried to explicitly cast every value and still getting the same error:
const NVMM_ConfigType NvmmCnf_Layout[6] =
{
{ (uint8_t)1, (uint32_t)1, (uint16_t)4},
{ (uint8_t)2, (uint32_t)3, (uint16_t)4},
{ (uint8_t)5, (uint32_t)5, (uint16_t)16},
{ (uint8_t)10, (uint32_t)1, (uint16_t)4},
{ (uint8_t)11, (uint32_t)2, (uint16_t)32},
{ (uint8_t)13, (uint32_t)1, (uint16_t)100},
};