P99
#define P99_REPEAT (   MACRO,
 
)    P99_FOR(MACRO, N, P00_SEQ, P00_REPEAT, P99_DUPL(N,))

Apply the macro MACRO N times.

The macro is called with the numbers 0, ..., N-1 and the N results are separated by a comma.

In the following example we define an adhoc macro that initializes an array element with a certain structure type. The array P is an array of 10 pairs, each containing their index in the index field and a different pointer in their aPos field.

 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) };
See also:
P99_UNROLL for a macro that separates the parts by ;
P99_SEQ for a similar macro that applies MACRO to a list of items
P99_FOR for a more Generic type expressions and Flexible array members utility
Remarks:
argument 0 should correspond to a macro name
argument 1 must expand to a decimal number

Definition at line 181 of file p99_for.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines