Skip to content

Instantly share code, notes, and snippets.

@linknum23
Created July 8, 2017 20:48
Show Gist options
  • Save linknum23/a087cae9da70a402d12ac8d1e4688dec to your computer and use it in GitHub Desktop.
Save linknum23/a087cae9da70a402d12ac8d1e4688dec to your computer and use it in GitHub Desktop.
Set the optimization level of a single c function in gcc
// You can use a Function Attribute called optimize to do this.
// I got the info on Function Attributes from this link:
// https://gcc.gnu.org/onlinedocs/gcc-4.5.4/gcc/Function-Attributes.html#Function-Attributes
// To set the optimization level to -O0 for a function:
void __attribute__ ((optimize("-O0"))) foo() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment