AnsweredAssumed Answered

What is the scope of pragma optimize commands?

Question asked by Ribred on Nov 7, 2013
Latest reply on Nov 8, 2013 by CraigG

The VDSP++ 5.0 C Compiler manual says on page 1-204

 

"General Optimization Pragmas

The compiler supports several pragmas which can change the optimization

level while a given module is being compiled. These pragmas must be used

globally, immediately prior to a function definition. The pragmas do not

just apply to the immediately following function; they remain in effect

until the end of the compilation, or until superseded by one of the following

optimize_ pragmas...."

 

A colleague reviewing my code is concerned about ambiguity as to scope of this pragma.  I say any pragma such as optimize_off only applies within a single file since the manual says it applies to a given module.  Therefore I issue a optimize_off at the start of a file related to hardware when I want no optimization then assume other code modules ( *.c, h etc files) will be optimized as command line by default.  He isn't sure.

 

I tried to add pragma optimize_as_cmd_line at the end of the file but since it doesn't precede a function it gives warnings. 

.\BSP\kvh_config.c

".\BSP\kvh_config.c", line 471: cc0606: {D} warning: this pragma must

          immediately precede a declaration

  #pragma optimize_as_cmd_line

 

 

Questions:

1) Does this pragma have module scope only or does it continue to apply to other modules compiled after the one containing it?

2) (I don't want to do this if I don't have to but...) should every file have a pragma optimize_as_cmd_line to make it unambiguous?

 

Thanks.

Outcomes