Enumeration specifier

6.6 Types

Moderators: misra-c, david ward

Locked
fwamolina
Posts: 8
Joined: Tue May 30, 2006 1:42 pm
Location: Argentine

Enumeration specifier

Post by fwamolina » Mon Jul 17, 2006 9:05 pm

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;

}
Embedded System

phaedsys
Posts: 50
Joined: Fri Sep 17, 2004 10:53 pm
Company: Phaedrus Systems
Location: Phaedrus Systems Tamworth, UK
Contact:

Re: Enumeration specifier

Post by phaedsys » Tue Jul 18, 2006 8:14 am

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?
This post is made in a personal capacity
Member of MISRA-C-WG since 2002

fwamolina
Posts: 8
Joined: Tue May 30, 2006 1:42 pm
Location: Argentine

Post by fwamolina » Tue Jul 18, 2006 1:44 pm

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.
Embedded System

bmerkle
Posts: 9
Joined: Mon Nov 15, 2004 6:44 am

Post by bmerkle » Fri Jul 21, 2006 7:38 am

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.

Locked

Return to “6.6 Types”