SlideShare a Scribd company logo
 1. ISO 9899 STANDARD
 2. COMBINATON OF C AND ASSEMBLY SHOULD
SUPPORT BY COMPILER
 4. RUN TIME CHECKING
 5. Use IOS C standard escape sequences
n, break, goto
 6. ISO 10646-1 rules for char types
 7. don’t use tri graphs
??-=~, ??)=]
 8. no multi byte char & wide string literals
Japanese, Chinese characters
 9. no nested comments
 10. not to comment code part
 11. Identifiers should not be >31
 14. char type should be signed or unsigned
 16. no bit representation of floating point
Use only decimal format
 17. typedef names shall not be reused
declare only once in header file
 18. use as bit_44 (suffix)
 19. octal constants shall not be used
c=052 052=42 in decimal
0 is used to represent for octal representation
 20. declarations of functions before using
 21. namespace shall not have same spellings
 24. no two identifiers should have internal &
external linkages
static i=0; extern i=0;
 25. An identifier with an external linkage
shall have exactly one external definition
 26. If objects are declared more than once
they shall have compatible declarations
delay function in multiple locations
 30. automatic variables have garbage values
 31. Braces shall be used to indicate and
match the structure in the non-zero
initialisation of arrays and structures
 Bit wise operations should not be
 Confused
 Performed on signed int
 38. shift operations
 16 bit integer should shift only in 0-15 range
 39. Unary minus
 t=100 and –t represents -100
 40. size of operator
 If(sizeof(y)==4) ok
 If(sizeof(f(z))==4) not ok
 41. Integer division based on compiler
 A=3/2
 A=3/-2
 A=3%2
 A/=2
 A%=-2
 42. comma operator should be used only in ctrl
expressions
 43. implicit conversions results in loss of
information
 Int32 I; int16 j,a;
 a=i*j;
 47. t=a*b+c/q; not ok
t=(a*b)+(c/q); ok
 48. int i=1,j=3; float k;
 K=i/j; to get precise value
 50. Float f=0.1234, g=0.1234;
 If(f==g) not to use
 52. every function should execute at least once
 54. if(i==k); while(1);
 Not to use
 Labels in switch statements
 Goto(avoid)
 Continue
 Break (use only in switch)
 If, if else, while must enclose in braces
 If, ifelse must have final else
 Every case of switch ends with break
 One default and one case is needed in switch
 Switch(x=y) don’t use
 Don’t use floating values for loop counters
 67.
 for(i=0;i<10;i++)
 {
 i=5;
 }
 Declare at file scope
 Variable no of arguments shall not be used
 Shall not call themselves
 Prototype declaration is needed
 Return type should match with the function
type
 Must have return type
 With no parameters declare as void
 #include---preceded by pre-processor directive
 C macros used
 #define pi 4
 Macros are not defined as #define’d
 Not to use #undef
 function-like macro shall not be 'called' without
all its arguments
 Arguments to a function-like macro shall not
contain tokens that look like pre-processing
directives
 each instance of a parameter, shall be enclosed
in parenthesis
#define TIMES2 ( x,y ) ( x* ( y ) )
 Identifiers in pre-processor directives should
be defined before use
 At least one preprocessor directive
 #pragma( libraries we can add to compilers)
need to be documented properly
 The defined pre-processor operator shall only
be used in one of the two standard forms
 #if defined d ok
 #if defined ( d ) ok
 #if defined "d" not ok
 Pointer arithmetic shall not be used
k = *pi;
k = * ( ++pi ) ; /* RULE 101 */
 No more than 2 levels of pointer indirection should be
used
k = ( *pi1 ) ;
k = ( * ( *pi2 ) ) ;
k = ( * ( * ( *pi3 ) ) ) ; /* RULE 102 */
 Relational operators shall not be applied to pointer types
except where both operands are of the same type
int m[10] = { 0,1,2,3,4,5,6,7,8,9 };
int n[10] = { 0,1,2,3,4,5,6,7,8,9 };
int *pm, *pmm;
pm = &m[1]; pmm = &m[3];
if ( pm < pmm ) { }
pmm = &n[3];
if( pm < pmm ) /* RULE 103 */ { }
 Non-constant pointers to functions shall not
be used
fp = ( int ( * ) ( ) ) func104b; /* RULE 104 */
 The null pointer shall not be dereferenced
 structure or union shall be fully specified
 struct s {
int mem;
foo; //108 rule
};
 Overlapping variable storage shall not be
used
 Bit fields shall only be defined to be one of
type unsigned int or signed int
static struct s{
int p_a : 4; /* RULE 111 */
signed int p_b : 4;
long p_e : 4; /* RULE 111 */} st;
 st.p_a = 0x1;
 Bit fields of type signed int shall be at least
2 bits long
 signed int p_a : 4;
 unsigned int p_b : 1;
 signed int p_c : 1; /* RULE 112 */
 All members shall be named and shall only
be access with their name
 unsigned int p_b : 1;
 signed int : 8; /* RULE 113 */
 unsigned int p_c : 4;
 Don’t change reserved key words
 Standard library names shall not be reused
 Should follow standard rules
 Dynamic heap memory allocation shall not be used
pd = malloc ( sizeof ( double ) ) ;
 The error indicator errno shall not be used
 Not to use
 Offsetof
 <local.h> and setlocale
 Setjmp macro, longjmp function
 Signal handling in <signal.h>
 <stdio.h>
 Atof, atoi, atol from<stslib.h>
 Abort, exit, getenv and system from <stdlib.h>
 Time handling of <time.h>
Misra c rules

More Related Content

What's hot

Autosar Basics hand book_v1
Autosar Basics  hand book_v1Autosar Basics  hand book_v1
Autosar Basics hand book_v1
Keroles karam khalil
 
System verilog verification building blocks
System verilog verification building blocksSystem verilog verification building blocks
System verilog verification building blocks
Nirav Desai
 
Linux Internals - Part III
Linux Internals - Part IIILinux Internals - Part III
Linux Internals - Part III
Emertxe Information Technologies Pvt Ltd
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
Mohamed Abdallah
 
Arduino Functions
Arduino FunctionsArduino Functions
Arduino Functions
mahalakshmimalini
 
SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
Anurag Tomar
 
Embedded C
Embedded CEmbedded C
ARM7TDM
ARM7TDMARM7TDM
ARM7TDM
Ramasubbu .P
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
linuxlab_conf
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
libfetion
 
The ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM ArchitectureThe ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM Architecture
sreea4
 
Verification Strategy for PCI-Express
Verification Strategy for PCI-ExpressVerification Strategy for PCI-Express
Verification Strategy for PCI-Express
DVClub
 
Linux device drivers
Linux device drivers Linux device drivers
Q4.11: ARM Architecture
Q4.11: ARM ArchitectureQ4.11: ARM Architecture
Q4.11: ARM Architecture
Linaro
 
Embedded C - Day 2
Embedded C - Day 2Embedded C - Day 2
Advanced C - Part 3
Advanced C - Part 3Advanced C - Part 3
Embedded Linux - Building toolchain
Embedded Linux - Building toolchainEmbedded Linux - Building toolchain
Embedded Linux - Building toolchain
Emertxe Information Technologies Pvt Ltd
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
Emertxe Information Technologies Pvt Ltd
 
STM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC blockSTM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC block
FastBit Embedded Brain Academy
 
Interrupts
InterruptsInterrupts

What's hot (20)

Autosar Basics hand book_v1
Autosar Basics  hand book_v1Autosar Basics  hand book_v1
Autosar Basics hand book_v1
 
System verilog verification building blocks
System verilog verification building blocksSystem verilog verification building blocks
System verilog verification building blocks
 
Linux Internals - Part III
Linux Internals - Part IIILinux Internals - Part III
Linux Internals - Part III
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
Arduino Functions
Arduino FunctionsArduino Functions
Arduino Functions
 
SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
 
Embedded C
Embedded CEmbedded C
Embedded C
 
ARM7TDM
ARM7TDMARM7TDM
ARM7TDM
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
The ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM ArchitectureThe ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM Architecture
 
Verification Strategy for PCI-Express
Verification Strategy for PCI-ExpressVerification Strategy for PCI-Express
Verification Strategy for PCI-Express
 
Linux device drivers
Linux device drivers Linux device drivers
Linux device drivers
 
Q4.11: ARM Architecture
Q4.11: ARM ArchitectureQ4.11: ARM Architecture
Q4.11: ARM Architecture
 
Embedded C - Day 2
Embedded C - Day 2Embedded C - Day 2
Embedded C - Day 2
 
Advanced C - Part 3
Advanced C - Part 3Advanced C - Part 3
Advanced C - Part 3
 
Embedded Linux - Building toolchain
Embedded Linux - Building toolchainEmbedded Linux - Building toolchain
Embedded Linux - Building toolchain
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
 
STM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC blockSTM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC block
 
Interrupts
InterruptsInterrupts
Interrupts
 

Viewers also liked

MISRA C Chairman - Device Developer Conference 2016
MISRA C Chairman - Device Developer Conference 2016MISRA C Chairman - Device Developer Conference 2016
MISRA C Chairman - Device Developer Conference 2016
Andrew Banks
 
MISRA C – Recent developments and a road map to the future
MISRA C – Recent developments and a road map to the futureMISRA C – Recent developments and a road map to the future
MISRA C – Recent developments and a road map to the future
AdaCore
 
MISRA Safety Case Guidelines -
MISRA Safety Case Guidelines - MISRA Safety Case Guidelines -
MISRA Safety Case Guidelines -
Automotive IQ
 
Misra c-2004
Misra c-2004Misra c-2004
Misra c-2004
sand390
 
MISRA-C as a functional programming with subset of C programming language
MISRA-C as a functional programming with subset of C programming languageMISRA-C as a functional programming with subset of C programming language
MISRA-C as a functional programming with subset of C programming language
Kiyoshi Ogawa
 
Development of Safety Case for the Wolsong LILW disposal facility in Korea
Development of Safety Case for the Wolsong LILW disposal facility in KoreaDevelopment of Safety Case for the Wolsong LILW disposal facility in Korea
Development of Safety Case for the Wolsong LILW disposal facility in Korea
Jin Beak Park
 
Misra cpp, cert cpp 2016 and RTL design style guide with HAZOP
Misra cpp, cert cpp 2016 and RTL design style guide with HAZOPMisra cpp, cert cpp 2016 and RTL design style guide with HAZOP
Misra cpp, cert cpp 2016 and RTL design style guide with HAZOP
Kiyoshi Ogawa
 
Multi-Core (MC) Processor Qualification for Safety Critical Systems
Multi-Core (MC) Processor Qualification for Safety Critical SystemsMulti-Core (MC) Processor Qualification for Safety Critical Systems
Multi-Core (MC) Processor Qualification for Safety Critical Systems
AdaCore
 
HIS Conf 2014: An Insight into MISRA-C
HIS Conf 2014: An Insight into MISRA-CHIS Conf 2014: An Insight into MISRA-C
HIS Conf 2014: An Insight into MISRA-C
AdaCore
 

Viewers also liked (9)

MISRA C Chairman - Device Developer Conference 2016
MISRA C Chairman - Device Developer Conference 2016MISRA C Chairman - Device Developer Conference 2016
MISRA C Chairman - Device Developer Conference 2016
 
MISRA C – Recent developments and a road map to the future
MISRA C – Recent developments and a road map to the futureMISRA C – Recent developments and a road map to the future
MISRA C – Recent developments and a road map to the future
 
MISRA Safety Case Guidelines -
MISRA Safety Case Guidelines - MISRA Safety Case Guidelines -
MISRA Safety Case Guidelines -
 
Misra c-2004
Misra c-2004Misra c-2004
Misra c-2004
 
MISRA-C as a functional programming with subset of C programming language
MISRA-C as a functional programming with subset of C programming languageMISRA-C as a functional programming with subset of C programming language
MISRA-C as a functional programming with subset of C programming language
 
Development of Safety Case for the Wolsong LILW disposal facility in Korea
Development of Safety Case for the Wolsong LILW disposal facility in KoreaDevelopment of Safety Case for the Wolsong LILW disposal facility in Korea
Development of Safety Case for the Wolsong LILW disposal facility in Korea
 
Misra cpp, cert cpp 2016 and RTL design style guide with HAZOP
Misra cpp, cert cpp 2016 and RTL design style guide with HAZOPMisra cpp, cert cpp 2016 and RTL design style guide with HAZOP
Misra cpp, cert cpp 2016 and RTL design style guide with HAZOP
 
Multi-Core (MC) Processor Qualification for Safety Critical Systems
Multi-Core (MC) Processor Qualification for Safety Critical SystemsMulti-Core (MC) Processor Qualification for Safety Critical Systems
Multi-Core (MC) Processor Qualification for Safety Critical Systems
 
HIS Conf 2014: An Insight into MISRA-C
HIS Conf 2014: An Insight into MISRA-CHIS Conf 2014: An Insight into MISRA-C
HIS Conf 2014: An Insight into MISRA-C
 

Similar to Misra c rules

Advanced C programming
Advanced C programmingAdvanced C programming
Advanced C programming
Claus Wu
 
C programming session8
C programming  session8C programming  session8
C programming session8
Keroles karam khalil
 
C programming session8
C programming  session8C programming  session8
C programming session8
Keroles karam khalil
 
C++_notes.pdf
C++_notes.pdfC++_notes.pdf
C++_notes.pdf
HimanshuSharma997566
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
rajatryadav22
 
Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)
tech4us
 
ch08.ppt
ch08.pptch08.ppt
ch08.ppt
NewsMogul
 
C –FAQ:
C –FAQ:C –FAQ:
C programming day#2.
C programming day#2.C programming day#2.
C programming day#2.
Mohamed Fawzy
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
SwapnaliPawar27
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic
Manzoor ALam
 
Operator overloading
Operator overloading Operator overloading
Operator overloading
Northeastern University
 
Data type
Data typeData type
Data type
Pratik Farkya
 
Workshop Swift
Workshop Swift Workshop Swift
Workshop Swift
Commit University
 
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.pptbtech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
chintuyadav19
 
Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
Pantech ProLabs India Pvt Ltd
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
javaTpoint s
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
Hattori Sidek
 
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdfguia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
SilvanildoManoeldaSi
 
C and data structure
C and data structureC and data structure
C and data structure
prabhatjon
 

Similar to Misra c rules (20)

Advanced C programming
Advanced C programmingAdvanced C programming
Advanced C programming
 
C programming session8
C programming  session8C programming  session8
C programming session8
 
C programming session8
C programming  session8C programming  session8
C programming session8
 
C++_notes.pdf
C++_notes.pdfC++_notes.pdf
C++_notes.pdf
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
 
Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)
 
ch08.ppt
ch08.pptch08.ppt
ch08.ppt
 
C –FAQ:
C –FAQ:C –FAQ:
C –FAQ:
 
C programming day#2.
C programming day#2.C programming day#2.
C programming day#2.
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic
 
Operator overloading
Operator overloading Operator overloading
Operator overloading
 
Data type
Data typeData type
Data type
 
Workshop Swift
Workshop Swift Workshop Swift
Workshop Swift
 
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.pptbtech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
 
Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdfguia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
 
C and data structure
C and data structureC and data structure
C and data structure
 

Recently uploaded

Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
Celine George
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
IsmaelVazquez38
 

Recently uploaded (20)

Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
 

Misra c rules

  • 1.
  • 2.  1. ISO 9899 STANDARD  2. COMBINATON OF C AND ASSEMBLY SHOULD SUPPORT BY COMPILER  4. RUN TIME CHECKING  5. Use IOS C standard escape sequences n, break, goto  6. ISO 10646-1 rules for char types  7. don’t use tri graphs ??-=~, ??)=]  8. no multi byte char & wide string literals Japanese, Chinese characters
  • 3.  9. no nested comments  10. not to comment code part  11. Identifiers should not be >31  14. char type should be signed or unsigned  16. no bit representation of floating point Use only decimal format  17. typedef names shall not be reused declare only once in header file
  • 4.  18. use as bit_44 (suffix)  19. octal constants shall not be used c=052 052=42 in decimal 0 is used to represent for octal representation  20. declarations of functions before using  21. namespace shall not have same spellings  24. no two identifiers should have internal & external linkages static i=0; extern i=0;
  • 5.  25. An identifier with an external linkage shall have exactly one external definition  26. If objects are declared more than once they shall have compatible declarations delay function in multiple locations  30. automatic variables have garbage values  31. Braces shall be used to indicate and match the structure in the non-zero initialisation of arrays and structures
  • 6.
  • 7.  Bit wise operations should not be  Confused  Performed on signed int  38. shift operations  16 bit integer should shift only in 0-15 range  39. Unary minus  t=100 and –t represents -100  40. size of operator  If(sizeof(y)==4) ok  If(sizeof(f(z))==4) not ok  41. Integer division based on compiler  A=3/2  A=3/-2  A=3%2  A/=2  A%=-2  42. comma operator should be used only in ctrl expressions
  • 8.  43. implicit conversions results in loss of information  Int32 I; int16 j,a;  a=i*j;  47. t=a*b+c/q; not ok t=(a*b)+(c/q); ok  48. int i=1,j=3; float k;  K=i/j; to get precise value  50. Float f=0.1234, g=0.1234;  If(f==g) not to use
  • 9.  52. every function should execute at least once  54. if(i==k); while(1);  Not to use  Labels in switch statements  Goto(avoid)  Continue  Break (use only in switch)  If, if else, while must enclose in braces  If, ifelse must have final else  Every case of switch ends with break  One default and one case is needed in switch  Switch(x=y) don’t use  Don’t use floating values for loop counters  67.  for(i=0;i<10;i++)  {  i=5;  }
  • 10.  Declare at file scope  Variable no of arguments shall not be used  Shall not call themselves  Prototype declaration is needed  Return type should match with the function type  Must have return type  With no parameters declare as void
  • 11.  #include---preceded by pre-processor directive  C macros used  #define pi 4  Macros are not defined as #define’d  Not to use #undef  function-like macro shall not be 'called' without all its arguments  Arguments to a function-like macro shall not contain tokens that look like pre-processing directives  each instance of a parameter, shall be enclosed in parenthesis #define TIMES2 ( x,y ) ( x* ( y ) )
  • 12.  Identifiers in pre-processor directives should be defined before use  At least one preprocessor directive  #pragma( libraries we can add to compilers) need to be documented properly  The defined pre-processor operator shall only be used in one of the two standard forms  #if defined d ok  #if defined ( d ) ok  #if defined "d" not ok
  • 13.  Pointer arithmetic shall not be used k = *pi; k = * ( ++pi ) ; /* RULE 101 */  No more than 2 levels of pointer indirection should be used k = ( *pi1 ) ; k = ( * ( *pi2 ) ) ; k = ( * ( * ( *pi3 ) ) ) ; /* RULE 102 */  Relational operators shall not be applied to pointer types except where both operands are of the same type int m[10] = { 0,1,2,3,4,5,6,7,8,9 }; int n[10] = { 0,1,2,3,4,5,6,7,8,9 }; int *pm, *pmm; pm = &m[1]; pmm = &m[3]; if ( pm < pmm ) { } pmm = &n[3]; if( pm < pmm ) /* RULE 103 */ { }
  • 14.  Non-constant pointers to functions shall not be used fp = ( int ( * ) ( ) ) func104b; /* RULE 104 */  The null pointer shall not be dereferenced  structure or union shall be fully specified  struct s { int mem; foo; //108 rule };  Overlapping variable storage shall not be used
  • 15.  Bit fields shall only be defined to be one of type unsigned int or signed int static struct s{ int p_a : 4; /* RULE 111 */ signed int p_b : 4; long p_e : 4; /* RULE 111 */} st;  st.p_a = 0x1;  Bit fields of type signed int shall be at least 2 bits long  signed int p_a : 4;  unsigned int p_b : 1;  signed int p_c : 1; /* RULE 112 */  All members shall be named and shall only be access with their name  unsigned int p_b : 1;  signed int : 8; /* RULE 113 */  unsigned int p_c : 4;
  • 16.  Don’t change reserved key words  Standard library names shall not be reused  Should follow standard rules  Dynamic heap memory allocation shall not be used pd = malloc ( sizeof ( double ) ) ;  The error indicator errno shall not be used  Not to use  Offsetof  <local.h> and setlocale  Setjmp macro, longjmp function  Signal handling in <signal.h>  <stdio.h>  Atof, atoi, atol from<stslib.h>  Abort, exit, getenv and system from <stdlib.h>  Time handling of <time.h>