MISRA 8.1 - 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.8 Declarations and Definitions (https://forum.misra.org.uk/forumdisplay.php?fid=35) +---- Thread: MISRA 8.1 (/showthread.php?tid=957) |
MISRA 8.1 - spd123 - 10-04-2013 Hi, [ MISRA 8.1 ] Functions shall have prototype and prototype shall be visible at both the definition and call I am using cystal revs for C MISRA C 2004 compliance. Its showing violation in following code. pl. suggest solution for this. controller specific header file ----------------------------------------- SFR( P0, 0x80U ); /* Port 0 Latch */ Main.c ---------- void main( void ) Global_Frame[ 0 ] = ( U8 )( Mid_No & 0x1fU ); /* bit of mid */ Re: MISRA 8.1 - misra-c - 16-04-2013 It is difficult to provide a detailed comment without seeing more context. SFR is presumably a function. If it were a macro then a violation of Rule 8.1 would not be expected and if it were a language extension then it would not conform to the ISO C language standard. Assuming that it is a function, the solution is to provide a suitable prototype declaration for it. There may even be such a declaration in a header file provided by the implementation. In the case of main, the solution again is to provide a suitable declaration at some point prior to the function definition. The return type and the number of parameters along with their types is implementation-defined in a freestanding implementation so provided your declaration and definition match each other and also match the requirements of your implementation there should be no problem. |