Skip to main content
ONadr.1
Senior III
November 28, 2022
Solved

Hello, I use Cube IDE, I would like to insert directives for the compiler into the code, for different optimization of parts of the code. How to do it?

..

This topic has been closed for replies.
KnarfB
KnarfBBest answer
Super User
November 29, 2022

The underlying compiler is gcc, so check the docs https://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html.

Basically, something like

#pragma GCC push_options
#pragma GCC optimize ("O0")
 
void my_function() {
...
}
 
#pragma GCC pop_options

will do the trick

hth

KnarfB

2 replies

KnarfB
KnarfBBest answer
Super User
November 29, 2022

The underlying compiler is gcc, so check the docs https://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html.

Basically, something like

#pragma GCC push_options
#pragma GCC optimize ("O0")
 
void my_function() {
...
}
 
#pragma GCC pop_options

will do the trick

hth

KnarfB

ONadr.1
ONadr.1Author
Senior III
November 29, 2022

Thanks a lot :grinning_face: