From stdcxx-commits-return-1630-apmail-incubator-stdcxx-commits-archive=incubator.apache.org@incubator.apache.org Tue Aug 14 22:48:24 2007 Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 77640 invoked from network); 14 Aug 2007 22:48:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Aug 2007 22:48:23 -0000 Received: (qmail 83697 invoked by uid 500); 14 Aug 2007 22:48:22 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 83684 invoked by uid 500); 14 Aug 2007 22:48:22 -0000 Mailing-List: contact stdcxx-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-commits@incubator.apache.org Received: (qmail 83673 invoked by uid 99); 14 Aug 2007 22:48:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Aug 2007 15:48:21 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Aug 2007 22:48:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 62DC81A981D; Tue, 14 Aug 2007 15:48:03 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r565959 - /incubator/stdcxx/trunk/etc/config/src/EXTERN_C_EXCEPTIONS.cpp Date: Tue, 14 Aug 2007 22:48:03 -0000 To: stdcxx-commits@incubator.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070814224803.62DC81A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 * 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