Archives

All posts for the month August, 2015

While writing C codes, many times you will need to write an array of input-output like pairs table. One of the most common example is to have a table containing state/command – function pointer pairs, which basically is a look up table of the function pointers to be executed based on the given input state/command. In this case, you would probably want to use X-macros to avoid/reduce mistakes in your code. Here is great tutorial on how to use x-macros for this purpose which I found on embedded.com:

http://www.embedded.com/design/programming-languages-and-tools/4403953/C-language-coding-errors-with-X-macros-Part-1

http://www.embedded.com/design/programming-languages-and-tools/4405283/Reduce-C–language-coding-errors-with-X-macros—Part-2

http://www.embedded.com/design/programming-languages-and-tools/4408127/Reduce-C-language-coding-errors-with-X-macros–Part-3

It is really worth to spend 30 minutes reading it!