Main OMNI definitions

for operator's scope

Some obsolete compilers uses incorrect scope of variables declared in the for loop. For example:

  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.

DEBUG mode

OMNI library has a DEBUG mode. In DEBUG mode library performs a lot of checking: indexes checking, iterators checking, etc. To enable DEBUG mode you should define OMNI_DEBUG macro to nonzero value. Also this macro may be 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.

MULTI-THREAD mode

OMNI library can be used in multithread environment. In this case access to any global or static resources (for example memory manager) should be synchronized between different threads.

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());
  }

UNICODE mode

OMNI library can be used be in UNICODE mode. If UNICODE mode is enabled, then instead char the wchar_t type is used (instead std::string the std::wstring is used corresponding).

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).

Math libraries

OMNI library can use some math libraries:

TODO: detail math libraries using description.

Author:
Sergey Polichnoy

Generated on Wed Jun 6 17:27:47 2007 for OMNI by  doxygen 1.5.2