【实例简介】MISRA--工业标准的C编程规范
【实例截图】
【核心代码】
Contents
Page
1. Background – the use of C and issues with it ........................................................................ 1
1.1 The use of C in the automotive industry ................................................................. 1
1.2 Language insecurities and the C language............................................................... 1
1.2.1 The programmer makes mistakes............................................................ 1
1.2.2 The programmer misunderstands the language........................................ 2
1.2.3 The compiler doesn’t do what the programmer expects.......................... 2
1.2.4 The compiler contains errors.................................................................. 2
1.2.5 Run-time errors...................................................................................... 3
1.3 The use of C for safety-related systems.................................................................. 3
1.4 C standardization ................................................................................................... 4
2. MISRA C: The vision........................................................................................................... 5
2.1 Rationale for the production of MISRA C.............................................................. 5
2.2 Objectives of MISRA C......................................................................................... 5
3. MISRA C: Developing the subset......................................................................................... 6
4. MISRA C: Scope ................................................................................................................. 7
4.1 Base language issues.............................................................................................. 7
4.2 Issues not addressed .............................................................................................. 7
4.3 Applicability........................................................................................................... 7
4.4 Safety Integrity Level issues................................................................................... 7
4.5 Prerequisite knowledge .......................................................................................... 8
4.6 C issues............................................................................................................. 8
4.7 Auto-generated code issues.................................................................................... 8
5. Using MISRA C................................................................................................................... 9
5.1 The software engineering context........................................................................... 9
5.2 The programming language and coding context...................................................... 9
5.2.1 Training ................................................................................................10
5.2.2 Style guide ............................................................................................10
5.2.3 Tool selection and validation .................................................................10
5.2.4 Source complexity metrics.....................................................................12
5.2.5 Test coverage........................................................................................12
5.3 Adopting the subset ..............................................................................................12
5.3.1 Compliance matrix ................................................................................13
5.3.2 Deviation procedure..............................................................................13
5.3.3 Formalisation within quality system .......................................................14
5.3.4 Introducing the subset...........................................................................14
5.4 Claiming compliance .............................................................................................15
5.5 Continuous improvement ......................................................................................15
vContents (continued)
Page
6. Introduction to the rules......................................................................................................16
6.1 Rule classification .................................................................................................16
6.1.1 Required rules.......................................................................................16
6.1.2 Advisory rules.......................................................................................16
6.2 Organisation of rules.............................................................................................16
6.3 Redundancy in the rules........................................................................................16
6.4 Presentation of rules .............................................................................................17
6.5 Understanding the source references.....................................................................18
6.5.1 Key to the source references..................................................................18
6.5.2 Understanding Annex G references........................................................19
7. Rules...................................................................................................................................20
7.1 Environment .........................................................................................................20
7.2 Character Sets ......................................................................................................22
7.3 Comments ............................................................................................................23
7.4 Identifiers .............................................................................................................23
7.5 Types....................................................................................................................24
7.6 Constants..............................................................................................................26
7.7 Declarations and Definitions..................................................................................27
7.8 Initialisation ..........................................................................................................29
7.9 Operators..............................................................................................................31
7.10 Conversions........................................................................................................34
7.11 Expressions.........................................................................................................35
7.12 Control Flow ......................................................................................................39
7.13 Functions............................................................................................................42
7.14 Pre-processing Directives....................................................................................46
7.15 Pointers and Arrays.............................................................................................50
7.16 Structures and Unions.........................................................................................51
7.17 Standard Libraries...............................................................................................53
8. References...........................................................................................................................58
Appendix A: Summary of rules................................................................................................59
Appendix B: Cross references to the ISO standard...................................................................67
网友评论
我要评论