I am familiar with std #defines and macro expansion for min max function but this one throws me. In particular the #'s in the definition. Your thoughts appreciated.
#define TAB_WIDGET_ROW(t) {t##_seq, t##_len, t##_rep}
I am familiar with std #defines and macro expansion for min max function but this one throws me. In particular the #'s in the definition. Your thoughts appreciated.
#define TAB_WIDGET_ROW(t) {t##_seq, t##_len, t##_rep}
You should read some documentation concerning the C Preprocessor. The ##
is about Concatenation. So an invocation like TAB_WIDGET_ROW(xy)
of your TAB_WIDGET_ROW
macro would probably be expanded to {xy_seq, xy_len, xy_rep}
The ##
is a C preprocessor standard macro used for concatenation.
This way, the code :
#define TAB_WIDGET_ROW(t) {t##_seq, t##_len, t##_rep}
int foo[3] = TAB_WIDGET_ROW(bar);
Will expand to :
int foo[3] = {bar_seq, bar_len, bar_rep};
And the foo
array will be filled with values of variables bar_seq
, bar_len
and bar_rep
.
See here for more informations.