--- Dimi Paun dimi@lattica.com wrote:
+#define SET_STRIDED (_usage, _name) \ +case _usage: \ +strided->u.s._name.lpData = data; \ +strided->u.s._name.dwType = element->Type; \ +strided->u.s._name.dwStride = stride; \ +break;
+#define SET_STRIDED_(_usage, _name) \ +case _usage: \ +strided->u.s._name.lpData = data; \ +strided->u.s._name.dwType = element->Type; \ +strided->u.s._name.dwStride = stride; \
This is pretty ugly: the resulting code doesn't look like C. In fact, it looks rather magical.For example, why pass in _usage as a param to the macro, just to get rid of the case _usage: which you actually want outside the macro for readability.
Well, when the #if 0's are removed the whole lot should fit on a screen so you can see the macro and it's usage quite clearly and it no longer looks like magic.
Also, accessing the magic strided, data, element, stride directly is very weird, and problematic. The casual user wouldn't know what hit him :)
It's less problematic since if forces the code into a strict layout, why have extra paramiters when there going to be identical? Every opportunity for a typo is an opportunity for a bug, less code less bugs, especially when it's being changed by the 'casual user'
I say let it be as is. If you really want the macro, something like this would be better:
Well, if I leave it as be, when I want to change the structure I have to change it ten times instead of once, that's ten times the opportunity for bugs.
It's just my opinion that when you reduce the amount of repetition in the code you reduce the possibility of error, and when the entire function is viewable without scrolling that adds to the readablity of the code.
+#define SET_STRIDED_(_strided, _name, _data, _element, _stride) \ +_strided->u.s._name.lpData = _data; \ +_strided->u.s._name.dwType = _element->Type; \ +_strided->u.s._name.dwStride = _stride;
-- Dimi Paun dimi@lattica.com Lattica, Inc.
___________________________________________________________ Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com