Fixed debug trap for Visual C++ and added debug trap for gcc/clang.

Based on code contributed by Halfdan Ingvarsson of Side Effects as openexr pull request #53
https://github.com/openexr/openexr/pull/53
Original commit: sideeffects/openexr@00c93c6fd5a3323b96daf91321703144100ccf1c
Iex::BaseExc is not a subclass of std::string, fixing msvc dllexport issues.
Use the _WIN32 pre-defined macro to check whether doing Win32 builds.

Following sideeffects/openexr@65b77868d8453784a2ea488157f35b1465c7b0c6