for (int i = 0; i < 10; ++i) { ... } for (int i = 0; i < 15; ++i) // error, "i" already defined { ... }
To fix this bug the following macro is used:
#define for if (false) {} else for
So the following code will be correct:
for (int i = 0; i < 10; ++i) { ... } for (int i = 0; i < 15; ++i) // OK { ... }
To fix for operator's scope you should define OMNI_FIX_FOR_SCOPE macro. For some compilers (for example MS VC++ 6.0) this macro is defined automatically.
OMNI_DEBUG_CODE macro includes debug code in to the source file only if DEBUG mode is enabled. If DEBUG mode disabled, then any debug code is ignored.
void f(int x) { OMNI_DEBUG_CODE(if (x<0) throw "value should be positive"); // ... }
Note, any checking in DEBUG mode are important for the OMNI library's users (i.e. programmers). For application's user some checking should be presented although DEBUG mode.
To enable MULTI-THREAD mode you should define OMNI_MT macro to nonzero value. Also this macro may be defined automatically.
OMNI_MT_CODE macro includes code in to the source file only if MULTI-THREAD mode is enabled. If MULTI-THREAD mode disabled, then any code is ignored.
#if OMNI_MT extern Lock __g_lock; #endif // OMNI_MT void f() { OMNI_MT_CODE(__g_lock.lock()); // ... OMNI_MT_CODE(__g_lock.unlock()); }
To enable UNICODE mode you should define OMNI_UNICODE macro to nonzero value. Also this macro may be defined automatically.
Note: although UNICODE mode OMNI library implements both versions (char and wchar_t). UNICODE macro is used to select default behavior only (in common case through typedef).
TODO: detail math libraries using description.