P99
|
◆ P99_REPEATApply the macro MACRO N times. The macro is called with the numbers In the following example we define an adhoc macro that initializes an array element with a certain structure type. The array typedef struct pair pair;
struct pair {
size_t index;
double* aPos;
};
#define ASIZE 10
double A[] = { P99_DUPL(ASIZE, 1.7) };
#define INIT_PAIR(I) [I] = { \
.index = I, \
.aPos = &A[I], \
}
pair P[] = { P99_REPEAT(INIT_PAIR, ASIZE) };
|