stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r565959 - /incubator/stdcxx/trunk/etc/config/src/EXTERN_C_EXCEPTIONS.cpp
Date Tue, 14 Aug 2007 22:48:03 GMT
Author: sebor
Date: Tue Aug 14 15:48:02 2007
New Revision: 565959

URL: http://svn.apache.org/viewvc?view=rev&rev=565959
Log:
2007-08-14  Martin Sebor  <sebor@roguewave.com>

	* EXTERN_C_EXCEPTIONS.cpp: New config test to determine whether
	it's possible to throw exceptions from functions with C language
	linkage.

Added:
    incubator/stdcxx/trunk/etc/config/src/EXTERN_C_EXCEPTIONS.cpp   (with props)

Added: incubator/stdcxx/trunk/etc/config/src/EXTERN_C_EXCEPTIONS.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/etc/config/src/EXTERN_C_EXCEPTIONS.cpp?view=auto&rev=565959
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/EXTERN_C_EXCEPTIONS.cpp (added)
+++ incubator/stdcxx/trunk/etc/config/src/EXTERN_C_EXCEPTIONS.cpp Tue Aug 14 15:48:02 2007
@@ -0,0 +1,57 @@
+// checking for exceptions from extern "C" functions
+
+// test tries to determine whether it's possible to throw exceptions
+// from functions with C language linkage
+
+extern "C" {
+
+int extern_c_function (int x, int y, int (*fun)(int, int))
+{
+    if (fun)
+        return fun (x, y);
+
+    return 0;
+
+}
+
+int div_throw (int x, int y)
+{
+    if (0 == y)
+        throw y;
+
+    return x / y;
+}
+
+int div_nothrow (int x, int y)
+{
+    if (0 == y)
+        return 0;
+
+    return x / y;
+
+}
+
+typedef int cfun_t (int, int);
+
+
+}   // extern "C"
+
+
+int main (int argc, char *argv[])
+{
+    const int x = argc < 2 ? 0 : int (*argv [1]);
+    const int y = argc < 3 ? 0 : int (*argv [2]);
+
+    cfun_t* pcfun = argc < 4 ? div_throw : div_nothrow;
+
+    int result;
+
+    try {
+        result = extern_c_function (x, y, pcfun);
+    }
+    catch (int res) {
+        result = res;
+    }
+
+    return result;
+}

Propchange: incubator/stdcxx/trunk/etc/config/src/EXTERN_C_EXCEPTIONS.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stdcxx/trunk/etc/config/src/EXTERN_C_EXCEPTIONS.cpp
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message