Embedded C Coding Rules

1. Using inline to replace #define when there are paramters

2. Using unsigned int only for bit-operations

3. Using fixed-width type int e.g. uint8_t, int8_t, etc.

4. Using const as many as you can to avoid mis-modification

5. Using static as many as you can to limit the functions/variables scope

6. Using volatile for interrupt or mutti-task shared varaibles

7. Using {} even there is only one line code in scope

8. Using const to replace #define Marco

 

more rules later

posted on 2020-07-27 12:15  荷树栋  阅读(147)  评论(0)    收藏  举报

导航