MISRA Discussion Forums

Full Version: Enumeration specifier
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My question is if there are one or more errors in this code?????????
Code:
/* file.h */
typedef enum tagColor {
  Rojo,
  Azul,
  Verde,
  Negro,
  Blanco
} Colors_t;

/* file.c */
#include \"file.h\"

void main (void)
{
  U32          u32value01;
  U32          u32value02;
  U16          u16value;
  Colors_t     enumcolor;

  u32value01 = Rojo;
  u32value02 = Blanco + Negro;

  u16value = 2U;

  enumcolor = u16value;

}
fwamolina Wrote:My question is if there are one or more errors in this code?????????

TO find out you should run a static analyser over it.....preferbly one with a MISRA-C checker. Otherwise I am sure some one will tell you their consultancy rates for checking code.

Did you have a specific MISRA-C question?
My friend there is 3 question implicit in this code dont you see?

line nro. 10 - implicit conversion betwen diferent type????
line nro 11 - complex expresion
line nro. 15 - same as line nro 10 in viceversa

just read the code and thank you my friend for answer me.
1. please be polite, questions with \"??????\" are not very good ;-)

2. please provide valid/compilable code. You example does not compile, because typedefs are missing... ;-)

3. this is no forum for \"analyse my code because i have no lint tool\" so a better approach would be to post you topic with questions like,

a. \"line x seems to violate MISRA-C rule Y.Z but i do not think so\"
\"can anyone explain or comment on this ?\"

b. seperate the issues and refer to the specific MISRA-C rule that you think is concerned.

kind regards,
Bernhard.