Skip to content

AUI_NO_OPTIMIZE_OUT#

Forbids object from being optimized out by compiler.

Header:#include <AUI/Traits/macros.h>
CMake:aui_link(my_target PUBLIC aui::core)

Definition#

#define AUI_NO_OPTIMIZE_OUT(object) { auto unused = &object ; }

Detailed Description#

Performs compiler hacks in order to prevent the compiler/linker from optimizing out the specified object. It's useful for debugging purposes, when the function is expected to exist to be called.

The macro should be called in any function/method which is not being optimized out (i.e. in destructor).

Basic usage:

struct SomeClass {
public:
  ~SomeClass() {
      AUI_NO_OPTIMIZE_OUT(SomeClass::debuggerMethod)
  }

  int debuggerMethod() {
    ...
  }
}