|
◆ P99_DO
#define P99_DO |
( |
|
TYPE, |
|
|
|
VAR, |
|
|
|
LOW, |
|
|
|
LEN, |
|
|
|
INCR |
|
) |
| for(;;) |
A fortran like do-loop with bounds that are fixed at the beginning.
- Parameters
-
TYPE | is the type of the control variable. It must be an arithmetic type. |
VAR | is the name of the control variable. It is not mutable inside the loop, as if it were declared TYPE const VAR . |
LOW | is the start value of VAR for the first iteration. Only evaluated once before all iterations. Must be assignment compatible to type TYPE. |
LEN | is the length of the iteration and is non-inclusive. Only evaluated once before all iterations. Must be assignment compatible to type TYPE. |
INCR | is the increment of VAR after each iteration. Only evaluated once before all iterations. INCR defaults to 1 if omitted. Must be assignment compatible to type TYPE. |
would expand to something similar to for ( size_t i = a; i < (a + n); i += inc) {
}
only that
- the bounds of the loop (involving
a and n ) and the increment inc are fixed once when entering this construct
- the loop variable
i is not modifiable within the block
- Warning
- Placing a
#pragma directive directly in front of P99_DO will not work because of syntactic restrictions. Use P99_PRAGMA_DO instead.
- See also
- P99_PARALLEL_DO for a parallel variant of this
-
P99_PRAGMA_DO for a variant of this that can be controlled with an arbitrary
#pragma directive.
- Examples
- test-p99-pow.c.
Definition at line 882 of file p99_for.h.
|