On December 26, 2002 04:06 pm, Chris Morgan wrote:
+/* Replace the scroll value with text */ +#define SCROLL_CODE_TEXT(nScrollCode) \ + (nScrollCode == SB_LINELEFT) ? "SB_LINELEFT" : (nScrollCode == SB_LINERIGHT) \ + ? "SB_LINERIGHT" : (nScrollCode == SB_INTERNAL) ? "SB_INTERNAL" : \ + (nScrollCode == SB_PAGELEFT) ? "SB_PAGELEFT" : (nScrollCode == \ + SB_PAGERIGHT) ? "SB_PAGERIGHT" : (nScrollCode == SB_THUMBPOSITION) ? \ + "SB_THUMBPOSITION" : (nScrollCode == SB_THUMBTRACK) ? \ + "SB_THUMBTRACK" : \ + (nScrollCode == SB_ENDSCROLL) ? "SB_ENDSCROLL" \ + : "unknown"
Please do not introduce such macros. I don't really think it's necessary to transform the code to text (it clutters the output), but if you insist on doing it, just do it through a function: static inline LPCSTR debugscrollcode(INT nScrollCode) { ... } This is the pattern used throughout listview.c. But in general speaking, if you can do it without macros, then macros are not the answer. -- Dimi.
Hmm.... for some reason I was thinking it had to be done via a macro but I suppose I can return a pointer to a static string just as easily. I figured someone would balk at that cool macro ;-) hahah Chris On Thursday 26 December 2002 09:51 pm, Dimitrie O. Paun wrote:
On December 26, 2002 04:06 pm, Chris Morgan wrote:
+/* Replace the scroll value with text */ +#define SCROLL_CODE_TEXT(nScrollCode) \ + (nScrollCode == SB_LINELEFT) ? "SB_LINELEFT" : (nScrollCode == SB_LINERIGHT) \ + ? "SB_LINERIGHT" : (nScrollCode == SB_INTERNAL) ? "SB_INTERNAL" : \ + (nScrollCode == SB_PAGELEFT) ? "SB_PAGELEFT" : (nScrollCode == \ + SB_PAGERIGHT) ? "SB_PAGERIGHT" : (nScrollCode == SB_THUMBPOSITION) ? \ + "SB_THUMBPOSITION" : (nScrollCode == SB_THUMBTRACK) ? \ + "SB_THUMBTRACK" : \ + (nScrollCode == SB_ENDSCROLL) ? "SB_ENDSCROLL" \ + : "unknown"
Please do not introduce such macros. I don't really think it's necessary to transform the code to text (it clutters the output), but if you insist on doing it, just do it through a function:
static inline LPCSTR debugscrollcode(INT nScrollCode) { ... }
This is the pattern used throughout listview.c. But in general speaking, if you can do it without macros, then macros are not the answer.
participants (2)
-
Chris Morgan -
Dimitrie O. Paun