Lkaf Temravet
Lkaf Temravet

Reputation: 993

tasking compiler disable optimisations

how can I disable optimisations with TASKING compiler ? I'm using eclipse IDE

I've read in the documentation that I could use #pragma but didnt understand how

If you specify a certain optimization, all code in the module is subject to that optimization. Within the C
source file you can overrule the C compiler options for optimizations with #pragma optimize flag
and #pragma endoptimize. Nesting is allowed:
#pragma optimize e /* Enable expression
... simplification */
... C source ...
...

Upvotes: 1

Views: 2966

Answers (1)

valiano
valiano

Reputation: 18601

It seems the TASKING compiler is compatible with GCC with respect to optimization level flags, per this user guide (which is indeed quite old).

For disabling optimizations altogether, select None (-O0) as optimization level in the C/C++ project settings. Note that -O0 is the default optimization level of the Debug configuration.

Screenshot (Eclipse Oxygen):

Eclipse set O0

If you wish to disable optimizations for a specific part of your C/C++ code, such as a specific function, then the pragma comes handy. For doing so place #pragma optimize 0 before the start of the code, and #pragma endoptimize after the end of it.

For example:

#pragma optimize 0
void myfunc()  
{
   // function body
}
#pragma endoptimize

Upvotes: 2

Related Questions