没有合适的资源?快使用搜索试试~ 我知道了~
首页AUTOSAR C++14 Coding stanards
资源详情
资源评论
资源推荐
Guidelines for the use of the C++14 language in critical and safety-related systems
AUTOSAR AP Release 17-10
Document Title
Guidelines for the use of the
C++14 language in cr itical and
safety-related systems
Document Owner AUTOSAR
Document Responsibility AUTOSAR
Document Identification No 839
Document Status Final
Part of AUTOSAR Standard Adaptive Platform
Part of Standard Release 17-10
Document Change History
Date Release Changed by
Description
2017-10-27 17-10
AUTOSAR
Release
Management
• Updated traceability for HIC, CERT,
C++ Core Guideline
• Partially included MISRA review of
the 2017-03 release
• Changes and fixes for existing rules,
more details in the Changelog (C.1)
2017-03-31 17-03
AUTOSAR
Release
Management
• Initial release
1 of 397
— AUTOSAR CONFIDENTIAL —
Document ID 839: AUTOSAR_RS_CPP14Guidelines
Guidelines for the use of the C++14 language in critical and safety-related systems
AUTOSAR AP Release 17-10
Disclaimer
This work (specification and/or software implementation) and the material contained in
it, as released by AUTOSAR, is for the purpose of information only. AUTOSAR and the
companies that have contributed to it shall not be liable for any use of the work.
The material contained in this work is protected by copyright and other types of
intellectual property rights. The commercial exploitation of the material contained in
this work requires a license to such intellectual property rights.
This work may be utilized or reproduced without any modification, in any form or by
any means, for informational purposes only. For any other purpose, no part of the work
may be utilized or reproduced, in any form or by any means, without permission in
writing from the publisher.
The work has been developed for automotive applications only. It has neither been
developed, nor tested for non-automotive applications.
The word AUTOSAR and the AUTOSAR logo are registered trademarks.
2 of 397
— AUTOSAR CONFIDENTIAL —
Document ID 839: AUTOSAR_RS_CPP14Guidelines
Guidelines for the use of the C++14 language in critical and safety-related systems
AUTOSAR AP Release 17-10
Contents
1 Background 7
2 The vision 8
2.1 Rationale for the production of AUTOSAR C++14 . . . . . . . . . . . . 8
2.2 Objectives of AUTOSAR C++14 . . . . . . . . . . . . . . . . . . . . . . 8
3 Scope 10
3.1 Allowed features of C++ language . . . . . . . . . . . . . . . . . . . . . 10
3.2 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Using AUTOSAR C++14 14
5 Introduction to the rules 15
5.1 Rule classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.1.1 Rule classification according to compatibility with MISRA . . 15
5.1.2 Rule classification according to obligation level . . . . . . . . 15
5.1.3 Rule classification according to enforcement by static analysis 15
5.1.4 Rule classification according to allocated target . . . . . . . . 16
5.2 Organization of rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.3 Exceptions to the rules . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.4 Redundancy in the rules . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.5 Presentation of rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.6 Understanding the issue references . . . . . . . . . . . . . . . . . . . . 17
5.7 Scope of rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6 AUTOSAR C++14 coding rules 18
6.0 Language independent issues . . . . . . . . . . . . . . . . . . . . . . . 18
6.0.1 Unnecessary constructs . . . . . . . . . . . . . . . . . . . . . 18
6.0.2 Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.0.3 Runtime failures . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.0.4 Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.1.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.1.2 Normative references . . . . . . . . . . . . . . . . . . . . . . 32
6.1.4 Implementation compliance . . . . . . . . . . . . . . . . . . . 33
6.2 Lexical conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.2.3 Character sets . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.2.5 Trigraph sequences . . . . . . . . . . . . . . . . . . . . . . . 35
6.2.6 Alternative tokens . . . . . . . . . . . . . . . . . . . . . . . . 35
6.2.8 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
6.2.9 Header names . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.2.11 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.2.14 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.3 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3 of 397
— AUTOSAR CONFIDENTIAL —
Document ID 839: AUTOSAR_RS_CPP14Guidelines
Guidelines for the use of the C++14 language in critical and safety-related systems
AUTOSAR AP Release 17-10
6.3.1 Declarations and definitions . . . . . . . . . . . . . . . . . . . 48
6.3.2 One Definition Rule . . . . . . . . . . . . . . . . . . . . . . . 51
6.3.3 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
6.3.4 Name lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
6.3.9 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
6.4 Standard conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
6.4.5 Integral promotions . . . . . . . . . . . . . . . . . . . . . . . 57
6.4.7 Integral conversion . . . . . . . . . . . . . . . . . . . . . . . . 60
6.4.10 Pointer conversions . . . . . . . . . . . . . . . . . . . . . . . 62
6.5 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.5.0 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.5.1 Primary expression . . . . . . . . . . . . . . . . . . . . . . . 73
6.5.2 Postfix expressions . . . . . . . . . . . . . . . . . . . . . . . 82
6.5.3 Unary expressions . . . . . . . . . . . . . . . . . . . . . . . . 90
6.5.6 Multiplicative operators . . . . . . . . . . . . . . . . . . . . . 92
6.5.8 Shift operators . . . . . . . . . . . . . . . . . . . . . . . . . . 92
6.5.10 Equality operators . . . . . . . . . . . . . . . . . . . . . . . . 93
6.5.14 Logical AND operator . . . . . . . . . . . . . . . . . . . . . . 94
6.5.16 Conditional operator . . . . . . . . . . . . . . . . . . . . . . . 94
6.5.18 Assignment and compound assignment operation . . . . . . 95
6.5.19 Comma operator . . . . . . . . . . . . . . . . . . . . . . . . . 95
6.5.20 Constant expression . . . . . . . . . . . . . . . . . . . . . . . 95
6.6 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
6.6.2 Expression statement . . . . . . . . . . . . . . . . . . . . . . 95
6.6.3 Compound statement or block . . . . . . . . . . . . . . . . . 96
6.6.4 Selection statements . . . . . . . . . . . . . . . . . . . . . . 96
6.6.5 Iteration statements . . . . . . . . . . . . . . . . . . . . . . . 99
6.6.6 Jump statements . . . . . . . . . . . . . . . . . . . . . . . . . 103
6.7 Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.7.1 Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.7.2 Enumeration declaration . . . . . . . . . . . . . . . . . . . . 113
6.7.3 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
6.7.4 The asm declaration . . . . . . . . . . . . . . . . . . . . . . . 119
6.7.5 Linkage specification . . . . . . . . . . . . . . . . . . . . . . 121
6.8 Declarators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
6.8.0 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
6.8.2 Ambiguity resolution . . . . . . . . . . . . . . . . . . . . . . . 125
6.8.3 Meaning of declarators . . . . . . . . . . . . . . . . . . . . . 126
6.8.4 Function definitions . . . . . . . . . . . . . . . . . . . . . . . 127
6.8.5 Initializers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
6.9 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
6.9.3 Member function . . . . . . . . . . . . . . . . . . . . . . . . . 137
6.9.5 Unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
6.9.6 Bit-fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
6.10 Derived Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
6.10.1 Multiple base Classes . . . . . . . . . . . . . . . . . . . . . . 143
4 of 397
— AUTOSAR CONFIDENTIAL —
Document ID 839: AUTOSAR_RS_CPP14Guidelines
Guidelines for the use of the C++14 language in critical and safety-related systems
AUTOSAR AP Release 17-10
6.10.2 Member name lookup . . . . . . . . . . . . . . . . . . . . . . 145
6.10.3 Virtual functions . . . . . . . . . . . . . . . . . . . . . . . . . 146
6.11 Member access control . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
6.11.0 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
6.11.3 Friends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
6.12 Special member functions . . . . . . . . . . . . . . . . . . . . . . . . . 156
6.12.0 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
6.12.1 Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
6.12.4 Destructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
6.12.6 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
6.12.7 Construction and destructions . . . . . . . . . . . . . . . . . 168
6.12.8 Copying and moving class objects . . . . . . . . . . . . . . . 170
6.13 Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
6.13.1 Overloadable declarations . . . . . . . . . . . . . . . . . . . 183
6.13.2 Declaration matching . . . . . . . . . . . . . . . . . . . . . . 186
6.13.3 Overload resolution . . . . . . . . . . . . . . . . . . . . . . . 189
6.13.5 Overloaded operators . . . . . . . . . . . . . . . . . . . . . . 190
6.13.6 Build-in operators . . . . . . . . . . . . . . . . . . . . . . . . 192
6.14 Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
6.14.0 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
6.14.1 Template parameters . . . . . . . . . . . . . . . . . . . . . . 193
6.14.5 Template declarations . . . . . . . . . . . . . . . . . . . . . . 195
6.14.6 Name resolution . . . . . . . . . . . . . . . . . . . . . . . . . 196
6.14.7 Template instantiation and specialization . . . . . . . . . . . 196
6.14.8 Function template specializations . . . . . . . . . . . . . . . 198
6.15 Exception handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
6.15.0 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
6.15.1 Throwing an exception . . . . . . . . . . . . . . . . . . . . . 218
6.15.2 Constructors and destructors . . . . . . . . . . . . . . . . . . 229
6.15.3 Handling an exception . . . . . . . . . . . . . . . . . . . . . . 233
6.15.4 Exception specifications . . . . . . . . . . . . . . . . . . . . . 244
6.15.5 Special functions . . . . . . . . . . . . . . . . . . . . . . . . . 252
6.16 Preprocessing directives . . . . . . . . . . . . . . . . . . . . . . . . . . 260
6.16.0 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
6.16.1 Conditional inclusion . . . . . . . . . . . . . . . . . . . . . . . 263
6.16.2 Source file inclusion . . . . . . . . . . . . . . . . . . . . . . . 263
6.16.3 Macro replacement . . . . . . . . . . . . . . . . . . . . . . . 266
6.16.6 Error directive . . . . . . . . . . . . . . . . . . . . . . . . . . 267
6.16.7 Pragma directive . . . . . . . . . . . . . . . . . . . . . . . . . 267
6.17 Library introduction - partial . . . . . . . . . . . . . . . . . . . . . . . . 268
6.17.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
6.17.2 The C standard library . . . . . . . . . . . . . . . . . . . . . . 270
6.17.3 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
6.18 Language support library - partial . . . . . . . . . . . . . . . . . . . . . 272
6.18.0 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
6.18.1 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
5 of 397
— AUTOSAR CONFIDENTIAL —
Document ID 839: AUTOSAR_RS_CPP14Guidelines
剩余396页未读,继续阅读
nightofnight
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
- MW全能培训汽轮机调节保安系统PPT教学课件.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论5