🎉 We're happy to announce a new public release 🎉

  • VX-toolset for TriCore - v6.4r1 - Software development environment of certified compiler toolsets for Infineon AURIX TC2xx/TC3xx microcontrollers
Contact us to get access

C compiler: Minimize the impact of disabling a specific optimization

02-Apr-2025

For the TASKING C compiler, enabling and disabling optimizations for the complete project or one of its modules can have a significant impact on the entire project.

With the #pragma optimize instructions you can selectively enable or disable specific optimizations at the source level, and obtain more fine-tuned results.

  • #pragma optimize [flags] controls the level of optimization.
    The remainder of the source line is scanned for option characters, which are processed similarly to the flags of the -O command line option.
  • #pragma optimize restore ends a region optimized with #pragma optimize.
    This
    restores the state as it was before the corresponding #pragma optimize.
#pragma optimize Y
[code]
#pragma optimize restore

In the above example, the peephole optimization is turned off for the code between the #pragma optimize instructions.

#pragma optimize/optimize restore pairs can be nested.


Was this answer helpful?