ShlubluLib  v0.5
ShlubluLib is a lightweight, modular, general purpose, open-source C++ library for Linux and Windows.
Macros
Debug.h File Reference

Go to the source code of this file.

Macros

#define SHLUBLU_TODO(msg)   _Pragma (__stringize(message "TODO: " msg))
 
#define SHLUBLU_DEBUG(msg)   _Pragma (__stringize(message "DEBUG: " msg))
 
#define SHLUBLU_OPTIMIZE_OFF()   _Pragma (__stringize(GCC warning "SHLUBLU_OPTIMIZE_OFF() has no effect with this platform."))
 

Detailed Description

Macros useful for developing and debugging: compilation messages, optimization control, and so on.

Macro Definition Documentation

◆ SHLUBLU_TODO

#define SHLUBLU_TODO (   msg)    _Pragma (__stringize(message "TODO: " msg))

Displays a compile-time "TODO" message.

Example

#include <util/Debug.h>
int main(void)
{
SHLUBLU_TODO("Doing something useful is needed here.");
return 0;
}

Output at compile time:

1>Main.cpp(5) : TODO: Doing something useful is needed here.

◆ SHLUBLU_DEBUG

#define SHLUBLU_DEBUG (   msg)    _Pragma (__stringize(message "DEBUG: " msg))

Displays a compile-time "DEBUG" message.

Example

#include <string>
#include <util/Debug.h>
std::string const& myBogusString()
{
SHLUBLU_DEBUG("Check this out, a bug has been reported around here.");
return "reference to temporary, this is likely to fail";
}

Output at compile time:

1>Feature.cpp(6) : DEBUG: Check this out, a bug has been reported around here.

◆ SHLUBLU_OPTIMIZE_OFF

#define SHLUBLU_OPTIMIZE_OFF ( )    _Pragma (__stringize(GCC warning "SHLUBLU_OPTIMIZE_OFF() has no effect with this platform."))

Prevent any compiler optimization from being performed in the current file after this statement.

This allows doing step-by-step debugging in release mode. This macro is only useful with Windows as its debug mode is very slow due to the numerous STL checks it performs at run-time. It is not implemented for Linux which has a workable debug mode: a warning is displayed instead.

Example

#include <util/Debug.h>
int main(void)
{
// stuff
return 0;
}

Output at compile time:

Windows:

1>Main.cpp(2) : DEBUG: All optimizations disabled

Linux:

1>Main.cpp(2,13): warning : SHLUBLU_OPTIMIZE_OFF() has no effect with this platform.
SHLUBLU_TODO
#define SHLUBLU_TODO(msg)
Definition: Debug.h:98
Debug.h
SHLUBLU_OPTIMIZE_OFF
#define SHLUBLU_OPTIMIZE_OFF()
Definition: Debug.h:101
SHLUBLU_DEBUG
#define SHLUBLU_DEBUG(msg)
Definition: Debug.h:99