MISRA C 4

Source: Internet
Author: User

19. Pre-processing instructions

1. The # include statements in the file can only be other preprocessing directives or annotations

2. #include指令中的头文件名字里不能出现非标准字符

3. #include预处理指令应该跟随 <filename> or "filename" sequence

4, C macros can only be extended to parentheses in the initialization, constants, parentheses around the expression, type qualifier, storage class identifier, or Do-while-zero

5. Macros cannot do # define and #undef in blocks

6. Do not use #undef

7, the function of the use of priority selection function macro (Function-like macro)

8, the function macro call cannot lack the parameter

9. A parameter passed to a function macro cannot contain a token that looks like a preprocessing directive.

10. When defining a function macro, each argument instance should be enclosed in parentheses unless they are the # or # #的操作数

11. All macro identifiers in pre-processing directives should be defined before use, except #ifdef and #ifndef directives and define () operators

12. A maximum of # and # #预处理器操作符 can appear in a single macro definition

13. Do not use # or # #预处理器操作符.

14. Defined preprocessor operators can only use one of two standard forms

15. Precautions should be taken to avoid the contents of a header file being included two times

16. Pre-processing instructions should be syntactically meaningful, even in the case of being excluded by the preprocessor

17. All #else, #elif和 #endif preprocessing instructions should be placed in the same file as the # if or #ifdef instructions associated with them


Standard library

1. Identifiers, macros, and functions reserved in the standard library cannot be defined, redefined, or undefined

2. The names of standard Ku Chonghong, objects, and functions cannot be reused

3. The value passed to the library function must be checked for validity

4. Cannot use dynamic heap memory allocation

5. Do not use error indication errno

6. The macro offsetof in library <stdde.h> should not be used

7. SETJMP macros and LONGJMP functions should not be used

8. Signal processing tools should not be used <signal.h>

9. The input/output library should not be used in the product code <stdio.h>

10. The functions Atof, Atoi, and ATOL in library <stdlib.h> should not be used

11. function in library <stdlib.h> abort, exit, getenv, and system should not be used

12. The time-processing function in library <time.h> should not be used


Run-time error

1. Minimizing run-time errors must ensure that at least one of the following methods is used:

A) static analysis tools/Technology

b) Dynamic analysis tools/Technology

c) display of code detection to handle run-time failures

MISRA C 4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.