Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enumeration specifier
#1
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;

}
<t>Embedded System</t>
#2
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?
<t>This post is made in a personal capacity<br/>
Member of MISRA-C-WG since 2002</t>
#3
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.
<t>Embedded System</t>
#4
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.


Forum Jump:


Users browsing this thread: 4 Guest(s)