A small freedom area. Templating in C Sat 28 Feb 2015 prog This question of how to make templating in C is often raised, and I couldn't find a good overview of the different approaches so I'll try to make a relatively exhaustive list here. Note: the methods presented here rely on the C preprocessor, which you can use directly yourself by calling the cpp command, paste your code and see the output by sending an EOS (pressing control + d typically). So the most common method is to dump some code enclosed (or not) into the do { ... } while (0) form: #define DO_RANDOM_STUFF(type) do { \ int i; \ type *p = buf; \ \ for (i = 0; i < len; i++) \ p[i] = p[i] * k; \ } while (0) ... and using it directly: int func ( void * buf , int len , float k , int request ) { if ( request == INT8 )...