Page 1 of 1

Enumeration specifier

Posted: Mon Jul 17, 2006 9:05 pm
by fwamolina
My question is if there are one or more errors in this code?????????

Code: Select all


/* 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

Posted: Tue Jul 18, 2006 8:14 am
by phaedsys
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?

Posted: Tue Jul 18, 2006 1:44 pm
by fwamolina
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.

Posted: Fri Jul 21, 2006 7:38 am
by bmerkle
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.