XCC Pragma Directives

The tools supports the following pragmas.

#pragma unsafe arrays

(XC Only) This pragma disables generation of run-time safety checks that prevent dereferencing out-of-bounds pointers and prevent indexing invalid array elements. If the pragma appears inside a function it applies to the body of the next do, while or for statement in that function. If the pragma appears outside a function the scope it applies to the body of the next function definition.

#pragma loop unroll (n)

(XC only) This pragma controls the number of times the next do, while or for loop in the current function is unrolled. n specifies the number of iterations to unroll, and unrolling is performed only at optimization level 01 and higher. Omitting the n parameter causes the compiler to try and fully unroll the loop. Outside of a function the pragma is ignored. The compiler produces a warning if unable to perform the unrolling.

#pragma stackfunction n

This pragma allocates n words (int s) of stack space for the next function declaration in the current translation unit.

#pragma stackcalls n

(XC only) This pragma allocates n words (int s) of stack space for any function called in the next statement. If the next statement does not contain a function call then the pragma is ignored; the next statement may appear in another function.

#pragma ordered

(XC only) This pragma controls the compilation of the next select statement. This select statement is compiled in a way such that if multiple events are ready when the select starts, cases earlier in the select statement are selected in preference to ones later on.

#pragma select handler

(XC only) This pragma indicates that the next function declaration is a select handler. A select handler can be used in a select case, as shown in the example below.

#pragma select handler
void f(chanend c, int &token, int &data);

...
select {
  case f(c, token, data):
    ...
    break;
}
...

The effect is to enable an event on the resource that is the first argument to the function. If the event is taken, the body of the select handler is executed before the body of the case.

The first argument of the select handler must have transmissive type and the return type must be void.

If the resource has associated state, such as a condition, then the select will not alter any of that state before waiting for events.

#pragma fallthrough

(XC only) This pragma indicates that the following switch case is expected to fallthrough to the next switch case without a break or return statement. This will suppress any warnings/errors from the compiler due to the fallthrough.