Next Previous Contents

19. Pragmas

SDCC supports the following #pragma directives. This directives are applicable only at a function level.

The pragma's are intended to be used to turn-off certain optimizations which might cause the compiler to generate extra stack / data space to store compiler generated temporary variables. This usually happens in large functions. Pragma directives should be used as shown in the following example, they are used to control options & optimizations for a given function; pragmas should be placed before and/or after a function, placing pragma's inside a function body could have unpredictable results.

eg#pragma SAVE   /* save the current settings */ 
#pragma NOGCSE
 /* turnoff global subexpression elimination */ 
#pragma NOINDUCTION /*
 turn off induction optimizations */ 
int foo () 
    /* large
 code */ 
#pragma RESTORE /* turn the optimizations back
 on */

The compiler will generate a warning message when extra space is allocated. It is strongly recommended that the SAVE and RESTORE pragma's be used when changing options for a function.

Next Previous Contents