Last active
March 9, 2020 10:11
-
-
Save redorav/f840f986042d8455fb59241a089c6342 to your computer and use it in GitHub Desktop.
Compiler-independent way of turning optimizations on and off for specific bits of code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if defined(_MSC_VER) | |
#define pragma_optimize_off __pragma(optimize("", off)); | |
#define pragma_optimize_on __pragma(optimize("", on)); | |
#elif defined(__clang__) | |
#define pragma_optimize_off _Pragma("clang optimize off") | |
#define pragma_optimize_on _Pragma("clang optimize on") | |
#elif defined(__GNUC__) | |
#define pragma_optimize_off _Pragma("GCC push_options") _Pragma("GCC optimize(\"O0\")") | |
#define pragma_optimize_on _Pragma("GCC pop_options") | |
#else | |
#define pragma_optimize_off | |
#define pragma_optimize_on | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment