MISRA Discussion Forums
Enumeration specifier - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.6 Types (https://forum.misra.org.uk/forumdisplay.php?fid=33)
+---- Thread: Enumeration specifier (/showthread.php?tid=287)



Enumeration specifier - fwamolina - 17-07-2006

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;

}



Re: Enumeration specifier - phaedsys - 18-07-2006

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?


- fwamolina - 18-07-2006

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.


- bmerkle - 21-07-2006

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.