Follow us on Google+ Follow us on Facebook Follow us on Twitter

Coding Tips

Preprocessor defines, macros, inline functions

  • Prefer using enum instead of preprocessor defines for constants
    • Preprocessor defines are only necessary when you are using the constant both in C and assembly sources
  • Prefer using static inline functions instead of preprocessor macros
    • Preprocessor macros are only needed (a) for type polymorphism, (b) if the result needs to be an l-value (R/W accessor)
  • Prefer using regular functions to static inline functions
    • Practically never needed, it is just premature optimization

Other Resources on Good Coding Practices

Last modified 2 years ago Last modified on 2015-03-31T16:30:47Z