35 ms·
"... and then use "counter_t" all over the place. I think that's not just ugly, but stupid and counter-productive. It makes it much harder to do things like "pr
by praptak 16y ago
"... and then use "counter_t" all over the place. I think that's not just ugly, but stupid and counter-productive. It makes it much harder to do things like "printk()" portably, for example ("should I use %u, %l or just %d?") ..."
Just do this: printk("count: " COUNTER_T_FORMAT_SPECIFIER "things", c);
- gjm11 16y agoSo instead of printk("subtotals: a %d, b %d, c %d, total %d\n", a,b,c,a+b+c); you have printk("subtotals: a " COUNTER_T_FORMAT_SPECIFIER ", b " COUNTER_T_FORMAT_SPECIFIER ", c " COUNTER_T_FORMAT_SPECIFIER ", total " COUNTER_T_FORMAT_SPECIFIER "\n", a,b,c,a+b+c); and soon you (1) can't read your code at all because 60% of it is shouty stuff in your calls to printk and (2) even the printk calls are awkward to read because your eyes have to skip over all the shouty stuff to work out what the output's actually going to look like. (Perhaps that was your point, in which case I apologize for thinking it needed spelling out more explicitly.)
- praptak 16y agoI was trying to be sarcastic.
- silentbicycle 16y agoIf you're going to be sarcastic, be so heavy-handed about it that you could sell it as a Methodology later. :) Otherwise, some people will take it at face value.
- larsu 16y agoPlease don't. I once dealt with code like this and it becomes unreadable very quickly, especially if many different types are involved. However, if printk would be declared with __attribute__((format(printf, 1, 2)) (I don't know if it is), gcc would warn if the format string contains specifiers which do not match the given types, regardless of any typedefs.