]> Creatis software - clitk.git/blobdiff - common/clitkCommon.h
Merge branch 'master' of tux.creatis.insa-lyon.fr:clitk
[clitk.git] / common / clitkCommon.h
index 97808d8d870ba778887a8ba98542cd3ea7ddf8b5..8f9ce0f0ee20fb8ad45b48f38876fc3d993695c5 100644 (file)
@@ -38,8 +38,9 @@
 #if defined(unix) || defined(__APPLE__)
 #  include <sys/time.h>
 #  include <sys/resource.h>
-#elif defined(WIN32)
+#elif defined(_WIN32)
 #  include <windows.h>
+#  include <stdint.h>
 #endif
 
 //--------------------------------------------------------------------
@@ -48,6 +49,24 @@ namespace clitk {
   typedef unsigned char uchar;
   typedef unsigned short ushort;
   typedef unsigned int uint;
+  
+#define CLITK_TRY_CATCH_EXIT(func) \
+  try { \
+    func; \
+  } \
+  catch (const itk::ExceptionObject& e) { \
+    e.Print(std::cout); \
+    exit(-1);\
+  } \
+  catch (const std::exception& e) { \
+    std::cout << e.what() << std::endl; \
+    exit(-2);\
+  } \
+  catch (...) { \
+    std::cout << "Unknown excpetion" << std::endl; \
+    exit(-3); \
+  }
+    
 
   //--------------------------------------------------------------------
   // when everything goes wrong