Pragmas
#pragma pure
Like
#pragma const
does not have any side effects (such as modifying global variables or data
buffers). However, the result returned may be a function of both the
parameter values and any global variables. The pragma may be applied to a
function prototype or definition. Two calls to the function with identical
parameters will always yield the same result provided that no global vari-
ables have been modified between the calls. Hence, calls to
functions may be hoisted out of loops if their parameters are loop inde-
pendent and no global variables are modified in the loop.
#pragma alloc
The
pragma alloc
library function. In particular, it returns a pointer to new memory
malloc
that cannot alias any pre-existing buffers. In the following code,
#pragma alloc
int *new_buf(void);
int *vmul(int *a, int *b) {
int i;
int *out = new_buf();
for (i=0; i<100; i++)
out[i] = a[i] * b[i];
}
Good: uses
the use of the pragma allows the compiler to be sure that the write into
buffer out does not modify either of the two input buffers
therefore, the iterations of the loop may be re-ordered.
2-32
, this pragma asserts to the compiler that a function
pragma asserts that the function behaves like the
to disambiguate out from
#pragma alloc
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
#pragma pure
and
.
a
b
or
, and,
a
b
for ADSP-219x DSPs
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?
Questions and answers