stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r332627 - /incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp
Date Fri, 11 Nov 2005 18:23:49 GMT
Author: sebor
Date: Fri Nov 11 10:23:45 2005
New Revision: 332627

URL: http://svn.apache.org/viewcvs?rev=332627&view=rev
Log:
2005-11-11  Martin Sebor  <sebor@roguewave.com>

	* NO_INT_TRAPS.cpp: Used Structured Exception Handling on Windows
	to prevent it from popping up a dialog box for the arithmetic
	exception triggered as a result of dividing by zero.

Modified:
    incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp

Modified: incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp?rev=332627&r1=332626&r2=332627&view=diff
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp (original)
+++ incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp Fri Nov 11 10:23:45 2005
@@ -4,6 +4,15 @@
 #  include "config.h"
 #endif   // _RWSTD_USE_CONFIG
 
+#if (defined (_WIN32) || defined (_WIN64)) && !defined (__CYGWIN__)
+#  define TRY             __try
+#  define EXCEPT(expr)    __except (expr)
+#else   // not Windows
+#  define TRY               if (1)
+#  define EXCEPT(ignore)    else if (0)
+#endif   // _WIN{32,64}
+
+
 int get_int ();
 
 int main (int argc, char*[])
@@ -11,7 +20,14 @@
     int int_zero = get_int ();
     int int_one  = get_int ();
 
-    int result = int_one / int_zero;
+    int result;
+
+    TRY {
+        result = int_one / int_zero;
+    }
+    EXCEPT (1) {
+        return 1;
+    }
 
     // NEGATIVE test: successful exit status indicates a failure
     return argc < 2 ? 0 : result;



Mime
View raw message