This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MISRA-C

MISRA stands for "Motor Industry Software Reliability Association". IAR has an Embedded Workbench which I believe is a Tester to verify the implementation for the MISRA C rules.

Does KEIL have a such a tool?

If there a PDF document available that spells out the rules. I have search and all I can find are test suites.

  • sir eric

    i be hit your nerve ends????

    sorry to you i saying

    i you think is right on cooding practice you think

    but you not thinkling make generel commment is bad yes with life?????

    i think you experience of years is very good and worth lot

    i now have experitnce to big rich programer but not good old years so you freind help me please????

  • you freind help me please????

    with WHAT

    Erik

  • Hi,

    its me, the bullshit man again ;-).

    I really think that MISRA is more academic but not for professionals. i have a lot of yars experience in professional development of embedded devicec in very very big projects.
    I dont need a kindergarden-guidance like MISRA. one rule is "dont use nonstandard language extensions". this is simply not possible in reality, like many more rules.

    understand me right, i am not against guidancees, but MISRA is one of the badest i have ever seen.

  • "with WHAT"

    sir eric

    no you not reading all message again!

    i being give youy complerment you know

    i say diffrent for you now

    yo have decedes of knowing and are good old and wise and clevere i be think

    you sometime giving good advicce and helping men

    but sometime i thinking you be obsterenentt ;)

    go help freind again now!!!!

  • please you should be writing message good like thiis firstly and say reeson is nice yes

    i thinking you not bigot now ;)

  • "one rule is "dont use nonstandard language extensions"."

    So for example, when using Keil C51 plus MISRA-C guidelines, one is limited to the memory models selectable at the toolchain level and can't mix; that is, use a predominantly small model with xdata-qualified objects where needed?

    Come to think of it now, one couldn't access SFRs either due to the way they are defined in the header files, right?

    Does anybody use C51 plus MISRA-C guidelines?

  • MISRA C--A set of guidelines meant to stifle the artistic freedom of fun-loving C developers worldwide.

    extracted from "

    Erik

  • one is limited to the memory models selectable at the toolchain level and can't mix;

    That's what that rule says, yes.

    Does anybody use C51 plus MISRA-C guidelines?

    I feel really sorry for anyone who has to do this.

  • There are 'rules' in MISRA C that makes for better software

    Of course. And of course those can be found in any book about good coding practices, along with the cases when it might make sense to break them (for example the "Goto must not be used." rule).

  • (for example the "Goto must not be used." rule).

    that rule is broken "every day by everybody"

    What is a switch statement but a bunch of "if - goto" statements?

    HOWEVER, the C 'structure' does not lend itself very well to the implemetation of GOTO, so, thinking of it I have no assembler that is not full of GOTO and no C that has any.

    Erik

  • that rule is broken "every day by everybody"<p>

    If you want to write code in compliance with MISRA-C rules, you better not break that rule, or your code will not comply with the standard anymore.

    Same thing goes for using a break; statement outside a switch/case structure, using a continue; statement, or using more than one return statement in a function.

  • "Same thing goes for using a break; statement outside a switch/case structure, using a continue; statement, or using more than one return statement in a function."

    Oops! Bad Dan. Bad, bad Dan!

  • that rule is broken that rule is broken "every day by everybody"<p>

    If you want to write code in compliance with MISRA-C rules, you better not break that rule, or your code will not comply with the standard anymore.

    I did not say anything about that an actual GOTO statement was used "every day by everybody", what I said is that a switch statement is the equivalent of (if - goto) and thus if you use a switch statement (which MISRA allows) you are in fact using GOTOs.

    Erik

  • "a switch statement is the equivalent of (if - goto)"

    equiverlent of goto in 8051 is jmp yes

    you be try writing assemblery with no jmp and yeou have only v little code you know

    but docomenent is MISRA-C not MISRA-8051 so not good to say equiverelent switch if-goto

    whot profffesional C coder do use goto????? i not know you know

    i do not you thinking yes

  • goto really is useful in some situations.

    However, all usage should be very similar to the usage of break and continue, but with the ability to make it multi-level, i.e. to break out of (or restart) more than one encapsulation.

    You might have a function:

    void fnk(void) {
    
    restart:
        do_something();
        for (;;) {
            do_more();
            switch (x) {
                case 1:
                    if (error) goto fail;
                    do_work();
                    break;
                case 10:
                    do_even_more();
                    break;
                default:
                    goto restart;
            }
        }
    
    fail:
        do_cleanup();
    }
    

    Yes, it is possible to solve all flow problems with flags, a large set of conditionals, and optional extra loops, but there comes a point where these flags gets very hard to read. The code must check if it should leave (or restart) first level, then second level, ...