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

猜你喜欢

转载自www.cnblogs.com/zjbfvfv/p/13384780.html